HWM_replace_links_to_current_mirror

Все ссылки на другие зеркала игры HWM заменяет на ссылки текущего сайта-зеркала игры

As of 2022-04-13. See the latest version.

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