HWM_MarkRealtyOnMap

Подсвечивает предприятия, акциями которых вы владеете. Подсвечивает на карте и в экономической статистике по арту

目前為 2023-08-12 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         HWM_MarkRealtyOnMap
// @namespace    http://tampermonkey.net/
// @version      1.5.2
// @description  Подсвечивает предприятия, акциями которых вы владеете. Подсвечивает на карте и в экономической статистике по арту
// @author       Zeleax
// @include /https?:\/\/(www.heroeswm.ru|178.248.235.15|www.lordswm.com|my.lordswm.com)\/(pl_info_realty.php|map.php|ecostat_details.php|auction.php\?cat=obj_share).*/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=lordswm.com
// @grant        none
// @license      MIT
// ==/UserScript==
// GM functions
if (typeof GM_getValue != 'function') {this.GM_getValue=function (key,def) {return localStorage[key] || def;};this.GM_setValue=function (key,value) {return localStorage[key]=value;};	this.GM_deleteValue=function (key) {return delete localStorage[key];};}

if(/map.php/.test(location.href)){
    document.body.addEventListener('click', function (evt) {
        if (evt.target.className.indexOf('job_fl_btn show_hint')==0) {
            if(/map.php.+st=(mn|fc|sh)/.test(evt.target.parentNode.href)){
                setTimeout(AA, 500);
            }
        }
    }, false);
}

AA();

function AA() {
    var HWM_objArr = GM_getValue('HWM_objArr',null);
    var objArr=JSON.parse(HWM_objArr);
    if(!objArr) objArr = [];

    var reg, list, el;

    if(/pl_info_realty.php/.test(location.href))
    {
        var heroId=/id=(\d+)/.exec(location.href)?.[1];
        if(heroId==getCurrentHeroWMId()){
            objArr = [];
            list=getL('//a[contains(@href,"object-info.php?id=") and contains(text(),"#")]');

            if(list.snapshotLength>0)
            {
                for (var i=0 ; i<list.snapshotLength; i++) objArr.push(/id=(\d+)/.exec(list.snapshotItem(i).href)[1]);
                var s_objArr=JSON.stringify(objArr);

                if(HWM_objArr!=s_objArr)
                {
                    GM_setValue('HWM_objArr',s_objArr);
                }
            }
        }
    }
    else if(/map.php/.test(location.href)){
        list=getL('//tr[starts-with(@class, "map_obj_table")]');
        var _row;

        for (i=0 ; i<list.snapshotLength; i++)
        {
            _row = list.snapshotItem(i);
            reg = /object-info.php\?id=(\d+)/.exec(_row.firstChild.firstChild.href);

            if((reg[1]) && objArr.includes(reg[1])) {
                _row.firstChild.style.backgroundColor = "yellow";
            }
        }
    }
    else if(/ecostat_details/.test(location.href)){
        list=getL('//td[a[contains(@href,"object-info")]]');
        var _td;

        for (i=0 ; i<list.snapshotLength; i++)
        {
            _td = list.snapshotItem(i);
            reg = /object-info.php\?id=(\d+)/.exec(_td.getElementsByClassName('pi')[0].href);

            if((reg[1]) && objArr.includes(reg[1])) _td.parentNode.style.backgroundColor = "yellow";
        }
    }
    else if(/auction.php\?cat=obj_share/.test(location.href)){
        list=getL('//a[contains(@href,"object-info.php?id=")]');
        for (i=0 ; i<list.snapshotLength; i++) {
            el=list.snapshotItem(i);
            el.href = el.href.replace('object-info','object_sh_info'); // заменяем ссылки на объекты ссылками на протоколы этих объектов
        }
    }
};

// доступ по xpath
function getE(xpath,el,docObj){return (docObj?docObj:document).evaluate(xpath,(el?el:(docObj?docObj.body:document.body)),null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;}
function getL(xpath,el,docObj){return (docObj?docObj:document).evaluate(xpath,(el?el:(docObj?docObj.body:document.body)),null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);}
function getCurrentHeroWMId(){var el=getE('//a[contains(@href,"pl_hunter_stat.php")]');if(el){return /id=(\d+)/.exec(el.href)?.[1];}}