HWM_WH_Art_IDs

Поиск артефакта по айди на странице склада (ctrl+shift+f); Показ айди при нажатии с зажатым Ctrl по строчке

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        HWM_WH_Art_IDs
// @namespace   Рианти
// @description Поиск артефакта по айди на странице склада (ctrl+shift+f); Показ айди при нажатии с зажатым Ctrl по строчке
// @include     http://www.heroeswm.ru/sklad_info.php?id=*
// @version     1.7
// @grant       none
// ==/UserScript==


var tables = document.querySelectorAll('table[width="970"] table.wb[width="970"]'),
    table = tables[tables.length - 1];
if (table.parentElement.nodeName == 'FORM') table = tables[tables.length - 2];

var links = table.querySelectorAll('a[href*="art_info.php?id="]'),t,t2;
for (var i = 0; i < links.length; i++){
    t = links[i].parentElement;
    while (!(t.firstChild.width == '50' || (t.firstChild.nextSibling && t.firstChild.nextSibling.width == '50'))) t = t.parentElement;
    if(!(t2 = links[i].href.match(/uid=(\d+)/))) continue;
    t.id = t2[1];
    t.className = 'artRow';
    t.onclick = function(e){
        if (e.ctrlKey){
            e.preventDefault();
            var p = e.target.parentElement;
            while(p.nodeName != 'TR') p = p.parentElement;
            var artId = p.querySelector('a[href*="art_info.php?id="]').href.match(/uid=(\d+)/)[1];
            prompt("Айди артефакта: ", artId);
        }
    }
}

window.onkeypress = function(e) {
    if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {
        if (e.shiftKey && e.ctrlKey && (e.keyCode == 6 || e.keyCode == 1)) {
            e.preventDefault();
            window.location.hash = prompt("Айди артефакта для поиска на странице:");
        }
    }
    else {
        if (e.shiftKey && e.ctrlKey && (e.key == 'F' || e.key == 'А')) {
            e.preventDefault();
            window.location.hash = prompt("Айди артефакта для поиска на странице:");
        }
    }
}

window.onhashchange = function(e){
    var artId = e.newURL.split('#')[1];
    var rows = document.getElementsByClassName('artRow');
    for (var i = 0; i < rows.length; i++) rows[i].style['background-color'] = '';
    document.getElementById(artId).style['background-color'] = '#F6E7D4';
}

if(window.location.hash != '' && document.getElementById(window.location.hash.split('#')[1])) document.getElementById(window.location.hash.split('#')[1]).style['background-color'] = '#F6E7D4';