Skip to content

Instantly share code, notes, and snippets.

@dragoncity17
Last active July 27, 2023 13:02
Show Gist options
  • Save dragoncity17/db748a6a68537c2eb5206b113d649f83 to your computer and use it in GitHub Desktop.
Save dragoncity17/db748a6a68537c2eb5206b113d649f83 to your computer and use it in GitHub Desktop.
AliExpress Modification cookie xman_us_f
// ==UserScript==
// @name AliExpress Modification cookie xman_us_f
// @description Modifier le cookie xman_us_f sur AliExpress
// @match *://*.aliexpress.com/*
// ==/UserScript==
// Thanks AndShy for your help ! :)
(function() {
'use strict';
// Nouvelle valeur du cookie xman_us_f à ajouter
var newValueToAdd = "&x_as_i=%7B%22channel%22%3A%22AFFILIATE%22%2C%22tagtime%22%3A1900000000000%7D";
// Vérifier si le cookie existe déjà
var currentCookie = document.cookie;
var cookieName = "xman_us_f=";
var cookieStartIndex = currentCookie.indexOf(cookieName);
// Vérifier si le cookie contient déjà la nouvelle valeur
if (currentCookie.includes(newValueToAdd)) {
return; // Rien à faire, la nouvelle valeur existe déjà dans le cookie
}
if (cookieStartIndex === -1) {
// Si le cookie n'existe pas, ajouter la nouvelle valeur complète
document.cookie = "xman_us_f=" + newValueToAdd;
} else {
// Si le cookie existe, ajouter la nouvelle valeur à la fin sans remplacer l'ancienne valeur
var cookieEndIndex = currentCookie.indexOf(";", cookieStartIndex);
var cookieValue = "";
if (cookieEndIndex === -1) {
cookieValue = currentCookie.substring(cookieStartIndex + cookieName.length);
} else {
cookieValue = currentCookie.substring(cookieStartIndex + cookieName.length, cookieEndIndex);
}
// Mettre à jour le cookie en ajoutant la nouvelle valeur à la fin
document.cookie = "xman_us_f=" + cookieValue + newValueToAdd;
}
})();
@AndShy
Copy link

AndShy commented Jul 27, 2023

You're welcome 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment