// ==UserScript== // @name 微软 Rewards 前台授权助手 // @namespace Soul233 // @version 0.3.0 // @author Soul233 // @description 微软积分商城签到配套脚本,捕获 https://login.live.com/oauth20_desktop.srf?code=... 并通过 @storageName 与后台通信 // @match https://login.live.com/oauth20_desktop.srf* // @grant GM_setValue // @grant GM_getValue // @grant GM_notification // @grant GM_log // @storageName rewards-bus // ==/UserScript== (function(){ "use strict"; const BUS = { PENDING: "auth:pending", RESULT: "auth:result" }; function log(s){ try{ GM_log("[FE] " + s); }catch(_){} } try{ const u = new URL(location.href); const code = u.searchParams.get("code"); const err = u.searchParams.get("error"); const pend = GM_getValue(BUS.PENDING, null); const id = pend?.id || ("manual-" + Date.now()); if (code){ log(`captured code (manual=${!pend})`); GM_setValue(BUS.RESULT, { id, code: String(code).trim(), ts: Date.now(), manual: !pend }); GM_notification({ title:"捕获到 code", text: String(code).slice(0,24)+"..." }); try{ history.replaceState({}, "", "about:blank"); }catch(_){} setTimeout(()=>{ try{ window.close(); }catch(_){ } }, 200); } else if (err){ GM_setValue(BUS.RESULT, { id, err: err, ts: Date.now(), manual: !pend }); } }catch(_){} })();