// ==UserScript== // @name 京东ck获取并提交到青龙_前台 // @namespace jdck // @storageName jdck // @version 0.1.3 // @description 在前端显示推送和一键登出按钮 // @author 王一之 // @run-at document-end // @match https://home.m.jd.com/myJd/newhome.action* // @match https://m.jd.com/* // @grant unsafeWindow // @grant GM_addValueChangeListener // @grant GM_setValue // @grant unsafeWindow // ==/UserScript== // 暂时无法实现 function clearAllCookie() { GM_setValue('logout', 'true'); } let push = document.createElement('button'); GM_addValueChangeListener('jdck', (name, old, newval, remote, tabid) => { console.log(newval, tabid); }); let ctl = document.createElement('div'); ctl.style.position = 'absolute'; ctl.style.zIndex = '1000'; ctl.style.padding = '10px'; ctl.style.left = '10px'; ctl.style.top = '200px'; ctl.style.background = 'red'; ctl.innerHTML = "
"; // ctl.innerHTML = ""; ctl.addEventListener('click', ev => { switch (ev.target.id) { case 'push-ck': GM_setValue('push-ck', 'request'); break; case 'logout': clearAllCookie(); setTimeout(() => { unsafeWindow.location = 'https://m.jd.com/'; }, 1000); break; } }); document.body.appendChild(ctl);