Greasy Fork

Greasy Fork is available in English.

FF14道具仓库批量领取

最终幻想14道具仓库批量领取

当前为 2019-09-15 提交的版本,查看 最新版本

// ==UserScript==
// @name         FF14道具仓库批量领取
// @description  最终幻想14道具仓库批量领取
// @namespace    http://greasyfork.icu/users/129402
// @match        http://act.ff.sdo.com/20170918Shop/index.html
// @grant        none
// @version      1.1.4
// @license      GNU General Public License v3.0 or later
// @compatible   chrome
// @compatible   firefox
// @compatible   opera
// @compatible   safari
// @run-at       document-end
// ==/UserScript==
/* eslint-disable no-magic-numbers */
"use strict";
(function () {
    let flag = false;
    const data = [];
    setInterval(() => {
        $(".lqspan[dataid][datatype][dataname]:not(.batch)").each(function () {
            const self = $(this);
            self.addClass("batch").attr("title", "只有勾选的才会批量领取");
            const input = $("<input/>");
            input.height(25);
            input.attr({
                "class": "lqcheckbox",
                type: "checkbox",
                title: "只有勾选的才会批量领取",
            });
            self.before(input);
        });
        if (flag) {
            flag = false;
            const item = data.shift();
            $.ajax({
                url: "http://act.ff.sdo.com/20170918Shop/Server/Warehouse.ashx",
                type: "POST",
                data: { method: "getItem", id: item.id, type: +item.type },
                success: (_) => {
                    try {
                        const d = JSON.parse(_);
                        if (d.Success) {
                            console.info(item.name, item.id, "领取成功~");
                            item.self.find(".prize").text("领取成功~");
                        } else { data.push(item); }
                        if (data.length > 0) { flag = true; }
                        else { setTimeout(() => alert("全部领取完成~"), 10); }
                    } catch (e) {
                        console.error(e);
                        data.push(item);
                        if (data.length > 0) { flag = true; }
                    }
                },
                error: (...args) => {
                    console.error(...args);
                    data.push(item);
                    if (data.length > 0) { flag = true; }
                },
            });
        }
    }, 100);
    const button = $("<a/>");
    button.addClass("back-btn").css({
        cursor: "pointer",
        "margin-right": "15px",
        background: "rgb(82, 150, 235)",
        "border-radius": "5px",
    }).attr("title", "只有勾选的才会批量领取");
    button.text("批量领取道具");
    const allButton = $("<a/>");
    allButton.css({
        cursor: "pointer",
        "margin-right": "15px",
        background: "rgb(114, 179, 66)",
        "border-radius": "5px",
    }).attr("title", "只有勾选的才会批量领取");
    allButton.text("全选");
    const noneButton = $("<a/>");
    noneButton.css({
        cursor: "pointer",
        "margin-right": "15px",
        background: "rgb(144, 144, 144)",
        "border-radius": "5px",
    });
    noneButton.text("全不选").attr("title", "只有勾选的才会批量领取");
    $(".rtbox").append(button).append(allButton).append(noneButton);
    button.on("click", function () {
        $(".lqcheckbox").each(function () {
            $(this).add($(this).next())[this.checked ? "addClass" : "removeClass"]("checked");
        });
        const target = $(".lqspan.checked[dataid][datatype][dataname]");
        if (target.length) {
            target.each(function () {
                data.push({
                    id: $(this).attr("dataid"),
                    type: $(this).attr("datatype"),
                    name: $(this).attr("dataname"),
                    self: $(this).closest("li"),
                });
            });
            alert("开始批量领取,请注意由于系统限制,领取速度可能稍慢~");
            flag = true;
        } else { alert("无物品可领取,请检查是否没有勾选物品~"); }
    });
    allButton.on("click", function () {
        $(".lqcheckbox").attr("checked", "checked");
    });
    noneButton.on("click", function () {
        $(".lqcheckbox").removeAttr("checked");
    });
})();