HWM_MarkRealtyOnMap

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

  1. // ==UserScript==
  2. // @name HWM_MarkRealtyOnMap
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5.3
  5. // @description Подсвечивает предприятия, акциями которых вы владеете. Подсвечивает на карте и в экономической статистике по арту
  6. // @author Zeleax
  7. // @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).*/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=lordswm.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12. // GM functions
  13. 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];};}
  14.  
  15. if(/map.php/.test(location.href)){
  16. document.body.addEventListener('click', function (evt) {
  17. if (evt.target.className.indexOf('job_fl_btn show_hint')==0) {
  18. if(/map.php.+st=(mn|fc|sh)/.test(evt.target.parentNode.href)){
  19. setTimeout(AA, 500);
  20. }
  21. }
  22. }, false);
  23. }
  24.  
  25. AA();
  26.  
  27. function AA() {
  28. var HWM_objArr = GM_getValue('HWM_objArr',null);
  29. var objArr=JSON.parse(HWM_objArr);
  30. if(!objArr) objArr = [];
  31.  
  32. var reg, list, el;
  33.  
  34. if(/pl_info_realty.php/.test(location.href))
  35. {
  36. var heroId=/id=(\d+)/.exec(location.href)?.[1];
  37. if(heroId==getCurrentHeroWMId()){
  38. objArr = [];
  39. list=getL('//a[contains(@href,"object-info.php?id=") and contains(text(),"#")]');
  40.  
  41. if(list.snapshotLength>0)
  42. {
  43. for (var i=0 ; i<list.snapshotLength; i++) objArr.push(/id=(\d+)/.exec(list.snapshotItem(i).href)[1]);
  44. var s_objArr=JSON.stringify(objArr);
  45.  
  46. if(HWM_objArr!=s_objArr)
  47. {
  48. GM_setValue('HWM_objArr',s_objArr);
  49. }
  50. }
  51. }
  52. }
  53. else if(/map.php/.test(location.href)){
  54. list=getL('//tr[starts-with(@class, "map_obj_table")]');
  55. var _row;
  56.  
  57. for (i=0 ; i<list.snapshotLength; i++)
  58. {
  59. _row = list.snapshotItem(i);
  60. reg = /object-info.php\?id=(\d+)/.exec(_row.firstChild.firstChild.href);
  61.  
  62. if((reg[1]) && objArr.includes(reg[1])) {
  63.  
  64. var cellsInRow = _row.getElementsByTagName('td');
  65. for (var j = 0; j < cellsInRow.length; j++) {
  66. cellsInRow[j].style.backgroundColor = 'yellow';
  67. }
  68. }
  69. }
  70. }
  71. else if(/ecostat_details/.test(location.href)){
  72. list=getL('//td[a[contains(@href,"object-info")]]');
  73. var _td;
  74.  
  75. for (i=0 ; i<list.snapshotLength; i++)
  76. {
  77. _td = list.snapshotItem(i);
  78. reg = /object-info.php\?id=(\d+)/.exec(_td.getElementsByClassName('pi')[0].href);
  79.  
  80. if((reg[1]) && objArr.includes(reg[1])) _td.parentNode.style.backgroundColor = "yellow";
  81. }
  82. }
  83. else if(/auction.php\?cat=obj_share/.test(location.href)){
  84. list=getL('//a[contains(@href,"object-info.php?id=")]');
  85. for (i=0 ; i<list.snapshotLength; i++) {
  86. el=list.snapshotItem(i);
  87. el.href = el.href.replace('object-info','object_sh_info'); // заменяем ссылки на объекты ссылками на протоколы этих объектов
  88. }
  89. }
  90. };
  91.  
  92. // доступ по xpath
  93. 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;}
  94. 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);}
  95. function getCurrentHeroWMId(){var el=getE('//a[contains(@href,"pl_hunter_stat.php")]');if(el){return /id=(\d+)/.exec(el.href)?.[1];}}