|
// ==UserScript== |
|
// @name AliExpress Cookie Mod |
|
// @namespace https://gist.github.com/and-rom/8f11e4d64b6dd0b6d7ff84688519d483 |
|
// @version 0.0.7 |
|
// @author and-rom |
|
// @description Modify Aliexpress cookies |
|
// @homepage https://gist.github.com/and-rom/8f11e4d64b6dd0b6d7ff84688519d483 |
|
// @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/8f11e4d64b6dd0b6d7ff84688519d483/raw/alicookiemod.meta.js |
|
// @downloadURL https://gist.github.com/and-rom/8f11e4d64b6dd0b6d7ff84688519d483/raw/alicookiemod.user.js |
|
// @match https://*.aliexpress.com/* |
|
// @match https://*.aliexpress.ru/* |
|
// @grant none |
|
// ==/UserScript== |
|
|
|
(function() { |
|
'use strict'; |
|
|
|
function extractHostname(url) { |
|
var hostname; |
|
if (url.indexOf("//") > -1) { hostname = url.split('/')[2]; } |
|
else { hostname = url.split('/')[0]; } |
|
hostname = hostname.split(':')[0]; |
|
hostname = hostname.split('?')[0]; |
|
return hostname; |
|
} |
|
|
|
function extractRootDomain(url) { |
|
var domain = extractHostname(url), |
|
splitArr = domain.split('.'), |
|
arrLen = splitArr.length; |
|
if (arrLen > 2) { |
|
domain = splitArr[arrLen - 2] + '.' + splitArr[arrLen - 1]; |
|
if (splitArr[arrLen - 2].length == 2 && splitArr[arrLen - 1].length == 2) { domain = splitArr[arrLen - 3] + '.' + domain; } |
|
} |
|
return domain; |
|
} |
|
|
|
function setCookie(name,value,days) { |
|
var expires = ""; |
|
if (days) { |
|
var date = new Date(); |
|
date.setTime(date.getTime() + (days*24*60*60*1000)); |
|
expires = "; expires=" + date.toUTCString(); |
|
} |
|
document.cookie = name + "=" + (value || "") + expires + "; path=/;domain=" + extractRootDomain(window.location.origin); |
|
} |
|
function getCookie(name) { |
|
var nameEQ = name + "="; |
|
var ca = document.cookie.split(';'); |
|
for(var i=0;i < ca.length;i++) { |
|
var c = ca[i]; |
|
while (c.charAt(0)==' ') c = c.substring(1,c.length); |
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); |
|
} |
|
return null; |
|
} |
|
function eraseCookie(name) { |
|
document.cookie = name+'=; Max-Age=-99999999;'; |
|
} |
|
|
|
function go() { |
|
var xman_us_f = getCookie('xman_us_f'); |
|
var flag = false; |
|
if (xman_us_f) { |
|
var new_xman_us_f = []; |
|
xman_us_f.split('&').forEach(function (item) { |
|
if ( item.split('=')[0] == "x_as_i" ) { |
|
flag = true; |
|
} else { |
|
new_xman_us_f.push(item); |
|
} |
|
}); |
|
if (flag) { |
|
setCookie('xman_us_f',new_xman_us_f.join('&'),25000); |
|
} |
|
} |
|
|
|
} |
|
|
|
if (document.readyState == "complete" || document.readyState == "loaded" || document.readyState == "interactive") { |
|
go(); |
|
} else { |
|
document.addEventListener("DOMContentLoaded", go); |
|
} |
|
})(); |