Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name GlobALIfier
- // @version 1.0
- // @include *://*.aliexpress.com/*
- // @run-at document-end
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- if (window.location.href.indexOf('://www.') == -1 && window.location.href.length > 100) {
- document.cookie = 'tmp_href=' + window.location.href;
- }
- var currencySwitcher = document.querySelector('#switcher-info > .currency');
- if (currencySwitcher && !(currencySwitcher.textContent == 'USD' || currencySwitcher.textContent == 'EUR')) {
- currencySwitcher.click();
- document.querySelector('a[data-currency="USD"]').click();
- document.querySelector('div[class*="ng-switcher"][data-role="region-pannel"] button[data-role="save"]').click();
- }
- var globalSiteButton = document.querySelector('a.link-goto-globalsite.notranslate');
- if (globalSiteButton) {
- globalSiteButton.click();
- }
- var previousUrl = document.cookie.match(new RegExp('(?:^|; )tmp_href=([^;]*)'));
- if (previousUrl) {
- var url = previousUrl[1].replace(/:\/\/[\w]+\./, '://www.');
- document.cookie = 'tmp_href=; expires=' + new Date(0).toUTCString();
- window.location.href = url;
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement