Advertisement
IntergalacticApps

GlobALIfier

Nov 12th, 2016
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           GlobALIfier
  3. // @version        1.0
  4. // @include        *://*.aliexpress.com/*
  5. // @run-at         document-end
  6. // @grant          none
  7. // ==/UserScript==
  8.  
  9. (function() {
  10.     'use strict';
  11.     if (window.location.href.indexOf('://www.') == -1 && window.location.href.length > 100) {
  12.         document.cookie = 'tmp_href=' + window.location.href;
  13.     }
  14.     var currencySwitcher = document.querySelector('#switcher-info > .currency');
  15.     if (currencySwitcher && !(currencySwitcher.textContent == 'USD' || currencySwitcher.textContent == 'EUR')) {
  16.         currencySwitcher.click();
  17.         document.querySelector('a[data-currency="USD"]').click();
  18.         document.querySelector('div[class*="ng-switcher"][data-role="region-pannel"] button[data-role="save"]').click();
  19.     }
  20.     var globalSiteButton = document.querySelector('a.link-goto-globalsite.notranslate');
  21.     if (globalSiteButton) {
  22.         globalSiteButton.click();
  23.     }
  24.     var previousUrl = document.cookie.match(new RegExp('(?:^|; )tmp_href=([^;]*)'));
  25.     if (previousUrl) {
  26.         var url = previousUrl[1].replace(/:\/\/[\w]+\./, '://www.');
  27.         document.cookie = 'tmp_href=; expires=' + new Date(0).toUTCString();
  28.         window.location.href = url;
  29.     }
  30. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement