window.scsite = {}; window.scsite.guild = function (id) { const _this = { // 自动弹出(需要GM_get/setValue权限) auto: function () { if (GM_getValue("guild", false)) { return; } const runDate = GM_getValue("runDate", 0); if (!runDate) { GM_setValue("runDate", new Date().getTime() / 1000); } else if (new Date().getTime() / 1000 - runDate > 600) { // 运行10分钟后弹出 _this.open(); } }, // 手动弹出 open: function () { const script = (GM_info && GM_info.script); if (!script) { script = { name: "NULL" }; } const div = document.createElement("div"); div.style.position = "fixed"; div.style.left = "50%"; div.style.top = "50%"; div.style.background = "#fff"; document.body.appendChild(div); const shadowRoot = div.attachShadow({ mode: 'open' }); let icon = ``; if (script.icon) { icon = `
` } else { icon = `
${script.name.substr(0, 1)}
` } shadowRoot.innerHTML = `
${icon}
喜欢"${script.name}"吗?
点击下方按钮在脚本猫中评分吧
取消前往
`; shadowRoot.querySelector(".cancel").onclick = function () { div.remove(); GM_setValue("guild", true); } shadowRoot.querySelector(".goto").onclick = function () { div.remove(); GM_setValue("guild", true); } } }; return _this; };