// ==UserScript== // @name AliExpress Links Change // @namespace https://gist.github.com/and-rom/6410c82f14c66711abfda7f0fa1cb5c0 // @version 0.5 // @author and-rom // @description Change links domain from .ru to .com // @homepage https://gist.github.com/and-rom/6410c82f14c66711abfda7f0fa1cb5c0 // @icon https://ae01.alicdn.com/images/eng/wholesale/icon/aliexpress.ico // @icon64 https://ae01.alicdn.com/images/eng/wholesale/icon/aliexpress.ico // @updateURL https://gist.github.com/and-rom/6410c82f14c66711abfda7f0fa1cb5c0/raw/alilinkschange.meta.js // @downloadURL https://gist.github.com/and-rom/6410c82f14c66711abfda7f0fa1cb5c0/raw/alilinkschange.user.js // @match https://*.aliexpress.com/* // @match https://*.aliexpress.ru/* // @grant none // ==/UserScript== (function() { 'use strict'; function go(links) { links.forEach(function(link){ if (link.hasAttribute("href")) { //console.log(link.getAttribute("href")); link.setAttribute("href", link.getAttribute("href").replace("aliexpress.ru", "aliexpress.com")); //console.log(link.getAttribute("href")); } }); } function setObserver() { var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; var observer = new MutationObserver(function(mutations, observer) { mutations.forEach(function( mutation ) { var newNodes = mutation.addedNodes; if (newNodes !== null && newNodes.length !== 0 && mutation.target.tagName !== "EM") { // If there are new nodes added //console.log(mutation); //console.log(newNodes); newNodes.forEach(function( newNode ) { if (newNode.nodeName === "#text" || newNode.nodeName === "#comment") return; var links = newNode.querySelectorAll('a'); if (links.length !== 0) go(links); //console.log(links); }); } }); }); observer.observe(document, { childList: true, subtree: true }); } document.addEventListener('keydown', function(e) { if (e.altKey) { var code = (e.keyCode ? e.keyCode : e.which); if (code == 82) { go(document.querySelectorAll('a')); } // Alt + r } }); var interval = setInterval(function() { if(document.readyState === 'complete') { clearInterval(interval); setObserver(); go(document.querySelectorAll('a')); } }, 100); })();