Last active
May 21, 2025 23:57
-
-
Save apfelchips/d8a6e08c1aeb79df4372096fd11c1fc1 to your computer and use it in GitHub Desktop.
Revisions
-
apfelchips revised this gist
Jul 23, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ // ==UserScript== // @name aliexpress_en // @version 0.2 // @description always redirect to aliexpress.com and reset the location/language/currency settings. This script pins locale settings cookie. Please clear cookies on all "aliexpress" domains before using this userscript. // @author @attero@mastodon.social // @match *://www.aliexpress.com/* -
apfelchips revised this gist
Jul 23, 2024 . 1 changed file with 0 additions and 20 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,10 +3,8 @@ // @version 0.1 // @description always redirect to aliexpress.com and reset the location/language/currency settings. This script pins locale settings cookie. Please clear cookies on all "aliexpress" domains before using this userscript. // @author @attero@mastodon.social // @match *://www.aliexpress.com/* // @match *://*.aliexpress.com/* // @match *://www.aliexpress.ru/* // @match *://*.aliexpress.ru/* // @noframes @@ -101,21 +99,3 @@ if ( ! xmanCookie.includes(`x_locale=${FORCE_LOCALE}`)) { const newxmanCookie = xmanCookie.replace(/x_locale=\w{2}_\w{2}/i, `x_locale=${FORCE_LOCALE}`) setCookie('xman_us_f', newxmanCookie, 9999) } -
apfelchips revised this gist
Nov 24, 2022 . 1 changed file with 15 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,9 @@ // @match *://www.aliexpress.com // @match *://www.aliexpress.com/* // @match *://*.aliexpress.com/* // @match *://www.aliexpress.ru // @match *://www.aliexpress.ru/* // @match *://*.aliexpress.ru/* // @noframes // @license MIT // @icon https://www.google.com/s2/favicons?sz=64&domain=aliexpress.com @@ -99,11 +102,20 @@ if ( ! xmanCookie.includes(`x_locale=${FORCE_LOCALE}`)) { setCookie('xman_us_f', newxmanCookie, 9999) } if (window.location.host.match(/^\w{2}\.aliexpress\.com/i)) { await new Promise(r => setTimeout(r, 800)) window.stop() log("redirecting to www.aliexpress.com", Style.red) const oldLocation = window.location.href const newLocation = oldLocation.replace(/\gatewayAdapt=glo2\w{3}/i, '').replace(/\w{2}\.aliexpress\.com/, "www.aliexpress.com") window.location = newLocation; } if (window.location.host.includes('aliexpress.ru')) { await new Promise(r => setTimeout(r, 800)) window.stop() log("redirecting to www.aliexpress.com", Style.red) const oldLocation = window.location.href const newLocation = oldLocation.replace('gatewayAdapt=glo2rus', '').replace('aliexpress.ru', "aliexpress.com") window.location = newLocation; } -
apfelchips revised this gist
Nov 24, 2022 . 1 changed file with 4 additions and 13 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,12 +6,10 @@ // @match *://www.aliexpress.com // @match *://www.aliexpress.com/* // @match *://*.aliexpress.com/* // @noframes // @license MIT // @icon https://www.google.com/s2/favicons?sz=64&domain=aliexpress.com // @supportURL https://gist.github.com/apfelchips/d8a6e08c1aeb79df4372096fd11c1fc1/ // ==/UserScript== // adapted from: https://greasyfork.org/en/scripts/447465-fix-com-to-ru-gatewayadapt-glo2rus-aliexpress-redirect-for-ukraine/code @@ -49,7 +47,7 @@ const Style = { ] } function log(input, extra = []) { let style = Style.base.join(';') + ';'; style += extra.join(';'); let logmsg = input @@ -76,7 +74,7 @@ function setCookie(cName, cValue, expDays) { const expires = `expires=${date.toUTCString()}` log(`setting cookie: ${cName}: ${cValue}`, Style.orange) document.cookie = `${cName}=${cValue}; ${expires}; path=/` } const aepCookie = getCookie('aep_usuc_f') const intlCookie = getCookie('intl_locale') @@ -101,18 +99,11 @@ if ( ! xmanCookie.includes(`x_locale=${FORCE_LOCALE}`)) { setCookie('xman_us_f', newxmanCookie, 9999) } await new Promise(r => setTimeout(r, 800)) // wait a bit so the modified cookies will be sent, otherwise this will end in a redirect loop if (window.location.host.match(/^\w{2}\.aliexpress\.com/)) { window.stop() const oldLocation = window.location.href const newLocation = oldLocation.replace(/\gatewayAdapt=glo2\w{3}/, '').replace(/\w{2}\.aliexpress\.com/, "www.aliexpress.com") window.location = newLocation; } -
apfelchips renamed this gist
Nov 24, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
apfelchips created this gist
Nov 24, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,118 @@ // ==UserScript== // @name aliexpress_en // @version 0.1 // @description always redirect to aliexpress.com and reset the location/language/currency settings. This script pins locale settings cookie. Please clear cookies on all "aliexpress" domains before using this userscript. // @author @[email protected] // @match *://www.aliexpress.com // @match *://www.aliexpress.com/* // @match *://*.aliexpress.com/* // @match *://www.aliexpress.ru // @match *://www.aliexpress.ru/* // @match *://*.aliexpress.ru/* // @noframes // @license MIT // @icon https://www.google.com/s2/favicons?sz=64&domain=aliexpress.com // ==/UserScript== // adapted from: https://greasyfork.org/en/scripts/447465-fix-com-to-ru-gatewayadapt-glo2rus-aliexpress-redirect-for-ukraine/code // doc: https://www.tampermonkey.net/documentation.php / https://violentmonkey.github.io/api/metadata-block/ const FORCE_SITE = 'glo' const FORCE_REGION = 'DE' const FORCE_LOCALE = 'en_US' const FORCE_CURRENCY = 'EUR' const Style = { base: [ "color: #fff", "background-color: #444", "padding: 2px 4px", "border-radius: 2px", "font-weight: bold" ], green: [ "background-color: green" ], red: [ "color: #eee", "background-color: red" ], blue: [ "background-color: blue" ], yellow: [ "color: #444", "background-color: yellow" ], orange: [ "background-color: orange" ] } const log = (input, extra = []) => { let style = Style.base.join(';') + ';'; style += extra.join(';'); let logmsg = input if ( typeof(input) == 'object'){ logmsg = JSON.stringify(input, null, 2).replace(/^[\t ]*"[^:\n\r]+(?<!\\)":/gm, (x) => x.replace(/"/g, '')) // json without quoted properties } console.log(`%c${logmsg}`, style); } function getCookie(cName) { var match = document.cookie.match(new RegExp('(^| )' + cName + '=([^;]+)')) if (match) { log(`found cookie: ${cName}: ${match[2]}`, Style.green) return match[2] } else { log(`empty/unset cookie: ${cName}: ''`, Style.yellow) return '' } } function setCookie(cName, cValue, expDays) { let date = new Date() date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000)) const expires = `expires=${date.toUTCString()}` log(`setting cookie: ${cName}: ${cValue}`, Style.orange) document.cookie = `${cName}=${cValue}; ${expires}; path=/` } const aepCookie = getCookie('aep_usuc_f') const intlCookie = getCookie('intl_locale') const xmanCookie = getCookie('xman_us_f') if (!(aepCookie.includes(`site=${FORCE_SITE}`) && aepCookie.includes(`region=${FORCE_REGION}`) && aepCookie.includes(`b_locale=${FORCE_LOCALE}`) && aepCookie.includes(`c_tp=${FORCE_CURRENCY}`) )) { // site=deu&c_tp=EUR&ups_d=&ups_u_t=®ion=DE&b_locale=de_DE&ae_u_p_s=1 const newaepCookie = `site=${FORCE_SITE}&c_tp=${FORCE_CURRENCY}&ups_d=&ups_u_t=®ion=${FORCE_REGION}&b_locale=${FORCE_LOCALE}&ae_u_p_s=1` setCookie('aep_usuc_f', newaepCookie, 9999) } if ( ! intlCookie.includes(`${FORCE_LOCALE}`)) { setCookie('intl_locale', FORCE_LOCALE, 9999) } if ( ! xmanCookie.includes(`x_locale=${FORCE_LOCALE}`)) { const newxmanCookie = xmanCookie.replace(/x_locale=\w{2}_\w{2}/i, `x_locale=${FORCE_LOCALE}`) setCookie('xman_us_f', newxmanCookie, 9999) } await new Promise(r => setTimeout(r, 600)) // wait a bit so the modified cookies will be sent, otherwise this will end in a redirect loop if (window.location.host.match(/^\w{2}\.aliexpress\.com/)) { window.stop() const oldLocation = window.location.href const newLocation = oldLocation.replace(/\gatewayAdapt=glo2\w{3}/, '').replace(/\w{2}\.aliexpress\.com/, "www.aliexpress.com") window.location = newLocation; } if (window.location.host.includes('aliexpress.ru')) { window.stop() const oldLocation = window.location.href const newLocation = oldLocation.replace('gatewayAdapt=glo2rus', '').replace('aliexpress.ru', "aliexpress.com") window.location = newLocation; }