Greasy Fork

Greasy Fork is available in English.

HWM_AutoReportMGTasks

Автосдача задания ГН

当前为 2017-11-25 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         HWM_AutoReportMGTasks
// @namespace    Небылица
// @version      1.1
// @description  Автосдача задания ГН
// @author       Небылица
// @include      /^https{0,1}:\/\/((www|qrator)\.heroeswm\.ru|178\.248\.235\.15)\/(map|mercenary_guild)\.php/
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(function() {
    'use strict';

    // скрипт требует для своей работы скрипт SetsMaster от Demin, который должен находиться выше по порядку исполнения
    if (document.getElementById("pers_gn").innerHTML.split(":").length === 3){
        if ((document.querySelector("a[href=\"map.php?cx=51&cy=50\"]") !== null) || (document.querySelector("a[href=\"map.php?cx=50&cy=48\"]") !== null) || (document.querySelector("a[href=\"map.php?cx=52&cy=48\"]") !== null) || (document.querySelector("a[href=\"map.php?cx=52&cy=53\"]") !== null)){
            var xhr = new XMLHttpRequest();
            var response;

            xhr.open('GET', "mercenary_guild.php", true);
            xhr.send();
            xhr.onreadystatechange = function() {
                if (this.readyState == 4 && this.status == 200) {
                    response = xhr.responseText;
                    if (response.indexOf("<b>Статус</b>") !== -1){
                        GM_setValue("reward", response.match(/<Br><br>(.+?)<table\sborder=0\scellspacing=0\scellpadding=0>/)[1]);
                        window.open("mercenary_guild.php", "_self");
                    }
                }
            };
        }
    }

    if (location.pathname.indexOf("mercenary_guild.php") !== -1 && GM_getValue("reward") !== "-1"){
        var td = document.querySelector("td[rowspan=\"2\"]");
        td.innerHTML = td.innerHTML.split("<table border")[0] + GM_getValue("reward") + "<table border"+ td.innerHTML.split("<table border")[1];
        GM_setValue("reward", "-1");
    }
})();