🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

AutoReblog2Queue

Make your Tumblr queue in a single key press.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         AutoReblog2Queue
// @namespace    https://github.com/KeyWeeUsr/Userscripts
// @version      1.0
// @description  Make your Tumblr queue in a single key press.
// @author       Peter Badida
// @copyright    2018+, Peter Badida
// @license      GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
// @homepage     https://github.com/KeyWeeUsr/Userscripts/tree/master/AutoReblog2Queue
// @supportURL   https://github.com/KeyWeeUsr/Userscripts/issues
// @icon         https://assets.tumblr.com/images/favicons/favicon.ico
// @include      https://www.tumblr.com/dashboard*
// @include      https://www.tumblr.com/dashboard/*
// @grant        unsafeWindow
// @contributionURL https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ACVM74AYCXVWQ
// ==/UserScript==
'use strict';

/**
 * Autoreblog to Queue
 *
 * Userscript for Tumblr Dashboard which automatically changes the reblogging
 * option to "Add to queue" and reblogs it immediately.
 *
 * Basically this little script takes an advantage of the already available
 * behavior of Tumblr keyboard shortcuts i.e. navigating via J and K keys
 * together with R for reblogging. The script works in the background, checks
 * whether the modal window is present (waits if not), changes the reblogging
 * options and then presses the "Queue" button (changed "Reblog" button).
 *
 * Just use these navigation keys: J (up), K (down), L (heart), R (reblog).
 *
 * You can toggle the autoreblogging script on/off with the Ctrl + Q keys.
 * It's turned on by default.
 *
 * Also, if you deactivated the script and pressed R (reblog), you can always
 * activate it back with Ctrl + Q keys and the script will automatically add
 * the current post you are reblogging to the queue.
 *
 * Notify me if there's something missing/undesirable.
 */

var DEBUG = false;

/* how often to check for reblog modal */
var INTERVAL = 500;


function sleep(ms) {
    var i;
    var start = new Date().getTime();

    while (i < 1e7) {
        if ((new Date().getTime() - start) > ms) {
            break;
        }
        i++;
    }
}


function reblog_to_queue() {
    var modal;
    var button;
    var arrow;
    var menu;
    var items;
    var i;

    /* find the modal window and wait if not available */
    modal = document.getElementsByClassName("post-forms-modal")[0];
    button = modal.getElementsByClassName("post-form--save-button");
    if (!button.length) {
        return;
    }

    /* modal window is available, reblog button is found, open the options */
    button = button[0];
    arrow = button.getElementsByClassName("icon_arrow_carrot_down")[0];
    arrow.click();

    /* find the options menu element and pull the items out */
    menu = modal.getElementsByClassName("pop-menu")[0];
    items = menu.getElementsByClassName("item-option");

    /* find the "Add to queue" option in the reblog options and select it */
    for (i = 0; i < items.length; i++) {
        if (items[i].innerText !== "Add to queue") {
            continue;
        }
        items[i].click();
        break;
    }

    /* press the reblog button */
    button.getElementsByTagName("button")[0].click();

    /**
     * and remove it from parent to prevent duplicates in the queue
     * from pressing the button multiple times via interval
     */
    button.parentNode.removeChild(button);
}


function bind_CtrlQ_keys() {
    var key;

    document.body.addEventListener("keydown", function(eve) {
        if (DEBUG) {
            console.log(window.autoreblogscript);
            console.log(eve);
        }

        /* get keycode from event */
        key = eve.which || eve.keyCode;

        /* check if Q and Ctrl are pressed */
        if (eve.ctrlKey && key == 81) {
            if (window.autoreblogscript) {
                /* toggle off */
                clearInterval(window.autoreblogscript);
                window.autoreblogscript = null;
                /* make sure the interval is really stopped */
                console.log("[AutoReblog2Queue] off");
            } else {
                /* toggle on */
                window.autoreblogscript = setInterval(
                    reblog_to_queue, INTERVAL
                );
                console.log("[AutoReblog2Queue] on");
            }
        }
    });
}


bind_CtrlQ_keys();
window.autoreblogscript = setInterval(reblog_to_queue, INTERVAL);