Skip to content

Instantly share code, notes, and snippets.

@and-rom
Last active December 13, 2021 11:28
Show Gist options
  • Select an option

  • Save and-rom/6410c82f14c66711abfda7f0fa1cb5c0 to your computer and use it in GitHub Desktop.

Select an option

Save and-rom/6410c82f14c66711abfda7f0fa1cb5c0 to your computer and use it in GitHub Desktop.

Revisions

  1. and-rom revised this gist May 21, 2020. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion alilinkschange.meta.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name AliExpress Links Change
    // @namespace https://gist.github.com/and-rom/6410c82f14c66711abfda7f0fa1cb5c0
    // @version 0.4
    // @version 0.5
    // @author and-rom
    // @description Change links domain from .ru to .com
    // @homepage https://gist.github.com/and-rom/6410c82f14c66711abfda7f0fa1cb5c0
    2 changes: 1 addition & 1 deletion alilinkschange.user.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name AliExpress Links Change
    // @namespace https://gist.github.com/and-rom/6410c82f14c66711abfda7f0fa1cb5c0
    // @version 0.4
    // @version 0.5
    // @author and-rom
    // @description Change links domain from .ru to .com
    // @homepage https://gist.github.com/and-rom/6410c82f14c66711abfda7f0fa1cb5c0
  2. and-rom revised this gist May 21, 2020. 2 changed files with 10 additions and 10 deletions.
    10 changes: 5 additions & 5 deletions alilinkschange.meta.js
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,14 @@
    // ==UserScript==
    // @name AliExpress Links Change
    // @namespace https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0
    // @version 0.3
    // @namespace https://gist.github.com/and-rom/6410c82f14c66711abfda7f0fa1cb5c0
    // @version 0.4
    // @author and-rom
    // @description Change links domain from .ru to .com
    // @homepage https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0
    // @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/androm/6410c82f14c66711abfda7f0fa1cb5c0/raw/alilinkschange.meta.js
    // @downloadURL https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0/raw/alilinkschange.user.js
    // @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
    10 changes: 5 additions & 5 deletions alilinkschange.user.js
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,14 @@
    // ==UserScript==
    // @name AliExpress Links Change
    // @namespace https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0
    // @version 0.3
    // @namespace https://gist.github.com/and-rom/6410c82f14c66711abfda7f0fa1cb5c0
    // @version 0.4
    // @author and-rom
    // @description Change links domain from .ru to .com
    // @homepage https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0
    // @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/androm/6410c82f14c66711abfda7f0fa1cb5c0/raw/alilinkschange.meta.js
    // @downloadURL https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0/raw/alilinkschange.user.js
    // @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
  3. and-rom revised this gist May 21, 2020. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion alilinkschange.meta.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name AliExpress Links Change
    // @namespace https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0
    // @version 0.1
    // @version 0.3
    // @author and-rom
    // @description Change links domain from .ru to .com
    // @homepage https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0
    2 changes: 1 addition & 1 deletion alilinkschange.user.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name AliExpress Links Change
    // @namespace https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0
    // @version 0.1
    // @version 0.3
    // @author and-rom
    // @description Change links domain from .ru to .com
    // @homepage https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0
  4. and-rom revised this gist May 21, 2020. 2 changed files with 19 additions and 4 deletions.
    15 changes: 15 additions & 0 deletions alilinkschange.meta.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    // ==UserScript==
    // @name AliExpress Links Change
    // @namespace https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0
    // @version 0.1
    // @author and-rom
    // @description Change links domain from .ru to .com
    // @homepage https://gist.github.com/androm/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/androm/6410c82f14c66711abfda7f0fa1cb5c0/raw/alilinkschange.meta.js
    // @downloadURL https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0/raw/alilinkschange.user.js
    // @match https://*.aliexpress.com/*
    // @match https://*.aliexpress.ru/*
    // @grant none
    // ==/UserScript==
    8 changes: 4 additions & 4 deletions alilinkschange.user.js
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,14 @@
    // ==UserScript==
    // @name AliExpress Links Change
    // @namespace https://gist.github.com/androm/[gist_id]
    // @namespace https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0
    // @version 0.1
    // @author and-rom
    // @description Change links domain from .ru to .com
    // @homepage https://gist.github.com/androm/[gist_id]
    // @homepage https://gist.github.com/androm/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/androm/[gist_id]/raw/[file_name].meta.js
    // @downloadURL https://gist.github.com/androm/[gist_id]/raw/[file_name].user.js
    // @updateURL https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0/raw/alilinkschange.meta.js
    // @downloadURL https://gist.github.com/androm/6410c82f14c66711abfda7f0fa1cb5c0/raw/alilinkschange.user.js
    // @match https://*.aliexpress.com/*
    // @match https://*.aliexpress.ru/*
    // @grant none
  5. and-rom created this gist May 21, 2020.
    67 changes: 67 additions & 0 deletions alilinkschange.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,67 @@
    // ==UserScript==
    // @name AliExpress Links Change
    // @namespace https://gist.github.com/androm/[gist_id]
    // @version 0.1
    // @author and-rom
    // @description Change links domain from .ru to .com
    // @homepage https://gist.github.com/androm/[gist_id]
    // @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/androm/[gist_id]/raw/[file_name].meta.js
    // @downloadURL https://gist.github.com/androm/[gist_id]/raw/[file_name].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);
    })();