Last active
December 13, 2021 11:28
-
-
Save and-rom/6410c82f14c66711abfda7f0fa1cb5c0 to your computer and use it in GitHub Desktop.
AliExpress Links Change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==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== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==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); | |
| })(); |
Author
А, если в этом смысле, то да.
А на счет поделиться ссылкой на товар без опасения, что кто-то увидит незнакомые символы... Если учитывать то, насколько рьяно aliexpress старается переадресовать посетителя на домен в его локальной зоне, я думаю, что, даже если кто-то за пределами России перейдет по ссылке в домене .ru, то aliexpress вероятно переадресует его на локальный домен (если у них такой конечно имеется.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@and-rom, я имею ввиду, что польза скрипта сейчас, кажется, только в том, что пользователь может отправить .com-ссылку на товар кому-то за пределами этой страны и не бояться, что получатель ссылки, перейдя по ней, увидит непонятные кириллические каракули (сайта aliexpress.ru).