HWM_replace_links_to_current_mirror

Все ссылки на другие зеркала игры HWM заменяет на ссылки к my.lordswm.com

La data de 06-05-2022. Vezi ultima versiune.

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 or Violentmonkey 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!)

  1. // ==UserScript==
  2. // @name HWM_replace_links_to_current_mirror
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.7.1
  5. // @description Все ссылки на другие зеркала игры HWM заменяет на ссылки к my.lordswm.com
  6. // @author Zeleax
  7. // @include /https:\/\/(www.heroeswm.ru|www.lordswm.com|my.lordswm.com|daily.heroeswm.ru)\/.*/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=lordswm.com
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. var cur_hostname= location.hostname;
  15.  
  16. var arr_hosts=['www.heroeswm.ru','my.lordswm.com','www.lordswm.com'].filter(function(o){ // сайты в ссылках для замены на текущее зеркало
  17. return o !== cur_hostname
  18. });
  19. var i, list;
  20.  
  21. list = getL('//a[contains(@href,"//") and not(contains(@href,"'+cur_hostname+'"))]');
  22.  
  23. var sethost= /daily.heroeswm.ru/.test(cur_hostname) ? 'my.lordswm.com' : cur_hostname;
  24.  
  25. for (i=0; i<list.snapshotLength; i++){
  26. for(var j=0; j<arr_hosts.length; j++){
  27. list.snapshotItem(i).href= list.snapshotItem(i).href.replace(arr_hosts[j], sethost);
  28. }
  29. }
  30.  
  31. // заменяем картинки и ссылки
  32. if(/lordswm/.test(cur_hostname) || /daily.heroeswm.ru/.test(cur_hostname)){
  33. list = getL('//img[contains(@src,"heroeswm.ru")]');
  34. for(i=0; i<list.snapshotLength; i++){
  35. list.snapshotItem(i).src=list.snapshotItem(i).src.replace(/dcdn.?.heroeswm.ru/,'cfcdn.lordswm.com');
  36. }
  37.  
  38. list = getL('//a[contains(@href,"heroeswm.ru")]');
  39. for(i=0; i<list.snapshotLength; i++){
  40. list.snapshotItem(i).href=list.snapshotItem(i).href.replace(/dcdn.?.heroeswm.ru/,'cfcdn.lordswm.com');
  41. }
  42. }
  43. })();
  44.  
  45. 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);}