Greasy Fork is available in English.
自动续期cookie,使网页端,易刷,apt等工具保持登陆状态,by:放课后
当前为
// ==UserScript==
// @license MIT
// @name POE自动续期cookie
// @namespace http://tampermonkey.net/
// @version 2024.5.18
// @description 自动续期cookie,使网页端,易刷,apt等工具保持登陆状态,by:放课后
// @author 放课后
// @match https://poe.game.qq.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=qq.com
// @grant none
// ==/UserScript==
(function() {
const today = new Date();
const nextYear = new Date();
nextYear.setFullYear(nextYear.getFullYear() + 1);
const expires = nextYear.toUTCString();
const cookieValues = document.cookie.match(`(^|;)\\s*p_uin\\s*=\\s*([^;]+)`);
const cookieValue = cookieValues ? cookieValues.pop() : '';
if(cookieValue){
document.cookie = `p_uin=${cookieValue}; expires=${expires}; path=/`;
}
if(window.location.href.indexOf("login") > -1){
// debugger
if(cookieValue){
console.log(cookieValue)
clearCookiesForDomain(window.location.hostname);
clearCookiesForDomain("poe.qq.com");
if(window.location.href != "https://poe.game.qq.com/login"){
window.location.href = "https://poe.game.qq.com/login"
}
}
}
function clearCookiesForDomain(domain) {
// 获取所有的cookie
const cookies = document.cookie.split(";");
// 遍历每一个cookie,并将其删除
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i];
const eqPos = cookie.indexOf("=");
const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
// 设置cookie的过期时间为过去的时间,以便删除cookie
document.cookie = name + `=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=${domain}`;
}
}
})();