// ==UserScript== // @name 知乎修改器移动版-持续更新 // @namespace http://tampermonkey.net/ // @version 1.1.0 // @description 知乎修改器的移动版:列表标题类别显示功能设置,收起按钮悬浮设置,列表、问题详情、回答、文章内容置顶创建和修改时间设置,一键获取内容链接设置,问题详情添加查看问题日志按钮,自定义样式,隐藏模块,缓存列表和浏览历史记录等功能。 // @compatible edge Violentmonkey // @compatible edge Tampermonkey // @compatible chrome Violentmonkey // @compatible chrome Tampermonkey // @compatible firefox Violentmonkey // @compatible firefox Tampermonkey // @author liuyubing // @license MIT // @match *://*.zhihu.com/* // @grant unsafeWindow // @grant GM_setValue // @grant GM_getValue // @grant GM.getValue // @grant GM.setValue // @grant GM_registerMenuCommand // @run-at document-start // @downloadURL none // ==/UserScript== "use strict"; (() => { var THEMES = [ { label: "浅色", value: "0" /* 浅色 */, background: "#fff", color: "#000" }, { label: "深色", value: "1" /* 深色 */, background: "#000", color: "#fff" }, { label: "自动", value: "2" /* 自动 */, background: "linear-gradient(to right, #fff, #000)", color: "#000" } ]; var THEME_CONFIG_LIGHT = { ["0" /* 默认 */]: { name: "默认", background: "#ffffff", background2: "" }, ["1" /* 红 */]: { name: "红", background: "#ffe4c4", background2: "#fff4e7" }, ["2" /* 黄 */]: { name: "黄", background: "#faf9de", background2: "#fdfdf2" }, ["3" /* 绿 */]: { name: "绿", background: "#cce8cf", background2: "#e5f1e7" }, ["4" /* 灰 */]: { name: "灰", background: "#eaeaef", background2: "#f3f3f5" }, ["5" /* 紫 */]: { name: "紫", background: "#e9ebfe", background2: "#f2f3fb" } }; var THEME_CONFIG_DARK = { ["0" /* 默认 */]: { name: "默认", color: "#fff", background: "#121212", background2: "#333333" }, ["1" /* 夜间护眼一 */]: { name: "夜间护眼一", color: "#f7f9f9", background: "#15202b", background2: "#38444d" }, ["2" /* 夜间护眼二 */]: { name: "夜间护眼二", color: "#f7f9f9", background: "#1f1f1f", background2: "#303030" }, ["3" /* 夜间护眼三 */]: { name: "夜间护眼三", color: "#f7f9f9", background: "#272822", background2: "#383932" } }; var INPUT_NAME_THEME = "theme"; var INPUT_NAME_THEME_DARK = "themeDark"; var INPUT_NAME_ThEME_LIGHT = "themeLight"; var NAME_CONFIG = "mobileConfig"; var NAME_HISTORY = "mobileHistory"; var HISTORY_DEFAULT = { view: [], list: [] }; var CONFIG_HIDDEN_DEFAULT = { hiddenOpenApp: true, hiddenReadMoreText: true, hiddenReward: true }; var CONFIG_FILTER_DEFAULT = {}; var CONFIG_DEFAULT = { ...CONFIG_HIDDEN_DEFAULT, ...CONFIG_FILTER_DEFAULT, openButtonTop: 100, openButtonLeft: 0, questionTitleTag: true, releaseTimeForList: true, releaseTimeForAnswer: true, releaseTimeForQuestion: true, releaseTimeForArticle: true, theme: "2" /* 自动 */, themeLight: "0" /* 默认 */, themeDark: "1" /* 夜间护眼一 */, copyAnswerLink: true, showQuestionLog: true }; var SAVE_HISTORY_NUMBER = 500; var HTML_HOOTS = ["www.zhihu.com", "zhuanlan.zhihu.com"]; var CLASS_INPUT_CLICK = "ctz-i"; var CLASS_INPUT_CHANGE = "ctz-i-change"; var CLASS_TIME_ITEM = "ctz-list-item-time"; var EXTRA_CLASS_HTML = { "zhuanlan.zhihu.com": "zhuanlan", "www.zhihu.com": "zhihu" }; var HEADER = [ { href: "#CTZ_BASIS", value: "基础设置" }, { href: "#CTZ_HIDDEN", value: "隐藏模块" }, // { href: '#CTZ_FILTER', value: '屏蔽内容' }, // { href: '#CTZ_BLOCK_WORD', value: '屏蔽词' }, // { href: '#CTZ_BLACKLIST', value: '黑名单' }, { href: "#CTZ_HISTORY", value: "历史记录" } // { href: '#CTZ_DEFAULT', value: '默认功能' }, ]; var HIDDEN_ARRAY = [ [ { value: "hiddenOpenApp", label: "隐藏跳转APP的提示和按钮" }, { value: "hiddenReward", label: "隐藏赞赏按钮" } ], [ { value: "hiddenLogo", label: "隐藏LOGO" }, { value: "hiddenHeader", label: "隐藏顶部悬浮模块" }, { value: "hiddenBottomSticky", label: "隐藏底部悬浮操作栏" } ], [ { value: "hiddenAnswers", label: "隐藏列表回答内容" }, { value: "hiddenListVideoContent", label: "隐藏列表视频回答的内容" }, { value: "hiddenListImg", label: "隐藏列表图片" }, { value: "hiddenReadMoreText", label: "隐藏列表「阅读全文」文字" } ], [ { value: "hiddenItemActions", label: "隐藏列表回答操作栏" }, { value: "hiddenAnswerItemActions", label: "隐藏详情回答操作栏" } ], [ { value: "hiddenQuestionFollowing", label: "隐藏关注问题按钮" }, { value: "hiddenQuestionAnswer", label: "隐藏问题写回答按钮" } ], [ { value: "hiddenAnswerItemTime", label: "隐藏回答底部发布编辑时间和IP" }, { value: "hiddenAnswerItemTimeButHaveIP", label: "隐藏回答底部发布编辑时间(保留IP)" } ], [ { value: "hiddenDetailAvatar", label: "隐藏回答人头像" }, { value: "hiddenDetailName", label: "隐藏回答人姓名" }, { value: "hiddenDetailBadge", label: "隐藏回答人简介" }, { value: "hiddenDetailVoters", label: "隐藏回答人下赞同数" }, { value: "hiddenWhoVoters", label: "隐藏回答人下 你赞同过、XXX赞同了 等信息" } ], [ { value: "hiddenZhuanlanAvatarWrapper", label: "隐藏文章作者头像" }, { value: "hiddenZhuanlanAuthorInfoHead", label: "隐藏文章作者姓名" }, { value: "hiddenZhuanlanAuthorInfoDetail", label: "隐藏文章作者简介" }, { value: "hiddenZhuanlanFollowButton", label: "隐藏文章作者关注按钮" }, { value: "hiddenZhuanlanTitleImage", label: "隐藏文章标题图片" }, { value: "hiddenZhuanlanActions", label: "隐藏文章底部悬浮操作栏" } ] ]; var myStorage = { set: async function(name, value) { value.t = +/* @__PURE__ */ new Date(); const v = JSON.stringify(value); localStorage.setItem(name, v); await GM.setValue(name, v); }, get: async function(name) { const config = await GM.getValue(name); const configLocal = localStorage.getItem(name); const cParse = config ? JSON.parse(config) : null; const cLParse = configLocal ? JSON.parse(configLocal) : null; if (!cParse && !cLParse) return ""; if (!cParse) return configLocal; if (!cLParse) return config; if (cParse.t < cLParse.t) return configLocal; return config; }, getConfig: async function() { const nConfig = await this.get(NAME_CONFIG); const c = nConfig ? JSON.parse(nConfig) : {}; const configSave = { ...CONFIG_DEFAULT, ...c }; return Promise.resolve(configSave); }, getHistory: async function() { const nHistory = await myStorage.get(NAME_HISTORY); const h = nHistory ? JSON.parse(nHistory) : HISTORY_DEFAULT; return Promise.resolve(h); }, /** 修改配置中的值 */ updateConfig: async function(key, value) { const config = await this.getConfig(); if (typeof key === "string") { config[key] = value; } else { for (let itemKey in key) { config[itemKey] = key[itemKey]; } } await this.set(NAME_CONFIG, config); }, /** 更新配置 */ setConfig: async function(params) { await this.set(NAME_CONFIG, params); }, setHistoryItem: async function(key, params) { const pfHistory = await this.getHistory(); pfHistory[key] = params.slice(0, SAVE_HISTORY_NUMBER); await this.set(NAME_HISTORY, pfHistory); }, setHistory: async function(value) { this.set(NAME_HISTORY, value); } }; var dom = (n) => document.querySelector(n); var domById = (id) => document.getElementById(id); var domA = (n) => document.querySelectorAll(n); var domC = (name, attrObjs) => { const node = document.createElement(name); for (let key in attrObjs) { node[key] = attrObjs[key]; } return node; }; var domP = (node, attrName, attrValue) => { const nodeP = node.parentElement; if (!nodeP) return void 0; if (!attrName || !attrValue) return nodeP; if (nodeP === document.body) return void 0; const attrValueList = (nodeP.getAttribute(attrName) || "").split(" "); return attrValueList.includes(attrValue) ? nodeP : domP(nodeP, attrName, attrValue); }; var fnReturnStr = (str, isHave = false, strFalse = "") => isHave ? str : strFalse; var fnLog = (...str) => console.log("%c「修改器」", "color: green;font-weight: bold;", ...str); var fnInitDomStyle = (id, innerHTML) => { const element = domById(id); element ? element.innerHTML = innerHTML : document.head.appendChild(domC("style", { id, type: "text/css", innerHTML })); }; function throttle(fn, time = 300) { let tout = void 0; return function() { if (tout) return; tout = setTimeout(() => { tout = void 0; fn.apply(this, arguments); }, time); }; } var pathnameHasFn = (obj) => { const { pathname } = location; for (let name in obj) { pathname.includes(name) && obj[name](); } }; var windowResize = () => { window.dispatchEvent(new Event("resize")); }; var copy = async (value) => { if (navigator.clipboard && navigator.permissions) { await navigator.clipboard.writeText(value); } else { const domTextarea = domC("textArea", { value, style: "width: 0px;position: fixed;left: -999px;top: 10px;" }); domTextarea.setAttribute("readonly", "readonly"); document.body.appendChild(domTextarea); domTextarea.select(); document.execCommand("copy"); document.body.removeChild(domTextarea); } }; var messageDoms = []; var message = (value, t = 3e3) => { const time = +/* @__PURE__ */ new Date(); const classTime = `ctz-message-${time}`; const nDom = domC("div", { innerHTML: value, className: `ctz-message ${classTime}` }); const domBox = domById("CTZ_MESSAGE_BOX"); if (!domBox) return; domBox.appendChild(nDom); messageDoms.push(nDom); if (messageDoms.length > 3) { const prevDom = messageDoms.shift(); prevDom && domBox.removeChild(prevDom); } setTimeout(() => { const nPrevDom = dom(`.${classTime}`); if (nPrevDom) { domById("CTZ_MESSAGE_BOX").removeChild(nPrevDom); messageDoms.shift(); } }, t); }; var createBtnTr = (innerHTML, extraCLass = "") => { return domC("button", { innerHTML, className: `ctz-button ctz-button-transparent ${extraCLass}`, style: "margin: 0 8px;" }); }; var hexToRgba = (hex, opacity) => { return "rgba(" + parseInt("0x" + hex.slice(1, 3)) + "," + parseInt("0x" + hex.slice(3, 5)) + "," + parseInt("0x" + hex.slice(5, 7)) + "," + opacity + ")"; }; var BASIC_SHOW_CONTENT = [ { label: "隐藏修改器唤起按钮,可在脚本菜单⚙️ 设置打开", value: "openButtonInvisible" }, { label: `列表标题类别显示问答文章视频想法`, value: "questionTitleTag", needFetch: false }, { label: "收起按钮悬浮", value: "suspensionPickup" }, { label: "列表内容置顶创建和修改时间", value: "releaseTimeForList" }, { label: "问题详情置顶创建和修改时间", value: "releaseTimeForQuestion" }, { label: "问题详情回答置顶创建和修改时间", value: "releaseTimeForAnswer" }, { label: "文章置顶创建时间", value: "releaseTimeForArticle" }, { label: "一键获取内容链接", value: "copyAnswerLink" }, { label: "问题详情显示查看问题日志按钮", value: "showQuestionLog" } ]; var myBackground = { init: async function() { const { themeDark = "1" /* 夜间护眼一 */, themeLight = "0" /* 默认 */ } = await myStorage.getConfig(); const innerHTML = await this.change(themeDark, themeLight); fnInitDomStyle("CTZ_STYLE_BACKGROUND", innerHTML); }, change: async function(themeDark, themeLight) { const getBackground = async () => { const isD = await this.isUseDark(); if (isD) return this.dark(themeDark); if (themeLight === "0" /* 默认 */) return this.default(); return this.light(themeLight); }; const strBg = await getBackground(); const strText = await this.text(); return strBg + strText; }, isUseDark: async () => { const { theme = "2" /* 自动 */ } = await myStorage.getConfig(); if (theme === "2" /* 自动 */) { const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)"); return prefersDarkScheme.matches; } return theme === "1" /* 深色 */; }, default: () => ".GlobalSideBar-navList{background: #fff}", dark: function(darkKey) { const { background, background2, color } = THEME_CONFIG_DARK[darkKey]; const whiteText = `#CTZ_DIALOG,.ctz-message,#CTZ_MAIN input,#CTZ_MAIN textarea,.ctz-footer,#CTZ_CLOSE_DIALOG,.ctz-commit,#CTZ_OPEN_BUTTON,.KfeCollection-VipRecommendCard-content,.KfeCollection-VipRecommendCard-title,#CTZ_DIALOG textarea,#CTZ_DIALOG .ctz-button,.ctz-button.ctz-button-transparent,body,.zu-top-nav-link,.CommentContent,[data-za-detail-view-path-module="CommentList"] div,.CommentsForOia div,.ctz-suspension-pickup,.zm-ac-link,.css-10noe4n,.css-3ny988,.css-hmd01z,.css-z0cc58,.css-7aa3bk,.css-1965tpd,.css-b574el,.css-1jg6wq6,textarea.zg-form-text-input,.zg-form-text-input>textarea,.css-1eglonx,.css-1tip2bd,.css-1symrae,.css-u3vsx3>div,.zm-editable-editor-field-wrap,.zu-question-suggest-topic-input,.zg-form-text-input,.zg-form-select{color: ${color}!important}`; const linkText = `.RelevantQuery li,.modal-dialog a,.ContentItem-more,.QuestionMainAction,a.UserLink-link,.RichContent--unescapable.is-collapsed .ContentItem-rightButton,.ContentItem-title a:hover,.css-b7erz1,.css-1vbwaf6,.css-1jj6qre,.css-jf1cpf{color: deepskyblue!important;}`; const addPrefix = (i) => { return i.split(",").map((i2) => `html[data-theme=dark] ${i2}`).join(","); }; const darkTransparentBg = `.ColumnHomeTop:before,.ColumnHomeBottom{background: transparent!important;}`; return addPrefix(this.doSetCSS(background, background2) + whiteText + linkText + darkTransparentBg) + this.doSetCSSInCTZ(background, background2) + `.MobileAppHeader-expandBackdrop{background: ${hexToRgba(background, 0.65)}!important;}`; }, light: function(lightKey) { const { background, background2 } = THEME_CONFIG_LIGHT[lightKey]; return this.doSetCSS(background, background2) + this.doSetCSSInCTZ(background, background2); }, /** 设置字体颜色 */ text: async function() { const { colorText1 } = await myStorage.getConfig(); const styleColorText1 = `.ContentItem-title, body{color: ${colorText1}!important;}`; return colorText1 ? styleColorText1 : ""; }, /** 知乎内元素样式设置 */ doSetCSS: function(background, background2) { const cssBg = `${this.cssNamesBackground1}{background-color: ${background}!important;}`; const cssBg2 = `${this.cssNamesBackground2}{background-color:${background2}!important;background:${background2}!important;}`; const cssBgTransparent = `${this.cssNamesBackgroundTransparent}{background-color: transparent!important;background: transparent!important;}`; const loadingStyle = `.css-w2vj5n{background: ${background}!important;color: ${background2}!important;}`; const borderBg = `.KfeCollection-VipRecommendCard-article{border-color: ${background}!important;}`; return cssBg + cssBg2 + cssBgTransparent + loadingStyle + borderBg; }, /** 修改器样式设置(不需要添加前缀) */ doSetCSSInCTZ: function(background, background2) { const menuTopBeforeAfter = `.ctz-menu>a.target::after,.ctz-menu>a.target::before{${this.menuBeforeAfter(background2)}}`; const openButton = `#CTZ_OPEN_BUTTON{background: ${background}!important;}`; return menuTopBeforeAfter + openButton; }, /** 使用背景色1的元素名称 */ cssNamesBackground1: `#CTZ_DIALOG,#CTZ_BASIS_SHOW label b,.ctz-suspension-pickup,.ctz-content-top a.target,.ctz-message,#CTZ_DIALOG textarea,#CTZ_DIALOG .ctz-button,body,.App,.MobileAppHeader-searchBox,.Input-wrapper,.VideoAnswerPlayer-stateBar,.ColumnHomeColumnCard,.Toast-root-tU3yo,.AuthorsSection-author-tFZJF,.editable,textarea.zg-form-text-input,.zg-form-text-input>textarea,.ac-active,.css-d1dtt9,.css-k8i00s,.css-41c1px,.zm-editable-editor-field-wrap,.zu-question-suggest-topic-input,.zg-form-text-input,.zg-form-select`, /** 使用背景色2的元素名称 */ cssNamesBackground2: `.ctz-content,.ctz-menu>a.target,.Card,.Sticky,.ContentItem-more,.ContentItem-actions,.Popover-content,.Popover-arrow:after,.MobileAppHeader-expand,.CommentsForOia>div,.KfeCollection-VipRecommendCard,.OpenInAppButton>div,.Modal-inner,.MobileSearch-container,.ProfileBar,.MobileAppHeader,.ZVideo-mobile,.Post-content,.sgui-header,.MobileCollectionsHeader-tabs,.MobileModal-title--default,.MobileModal,.List-item,.Login,.Input-wrapper.SignFlow-accountInput,.SignFlowInput .Input-wrapper,.SearchTabs,.MobileEmptyPageWithType,.TopicHot-Header,.Favlists-mobileActions,[data-za-detail-view-path-module="SearchResultList"]>div,[data-za-detail-view-path-module="SearchResultList"]>div>a,.SearchSubTabs,.KfeCollection-PcCollegeCard-root,.modal-dialog,.ac-renderer,.css-hplpcn,.zh-add-question-form .add-question-splash-page .ac-renderer .ac-row.ac-last,.HeaderInfo-infoCard-orDxs,.Common-content-893LU,.ContentModule-module-9gTaH,.NewBottomBar-root-dVXzD,.AuthorModule-root-rxFMb,.css-w0m1iq,.zu-autocomplete-row-label,.ac-row.zu-autocomplete-row-search-link,.css-1e7fksk,.css-1gfesro,.css-ud510h,.css-vb0amv,.css-t89z5u,.css-u3vsx3>div,.css-5k4zcx,.css-13heq6w,.css-13heq6w>a,.css-1eltcns,.css-yoby3j,.css-l63y2t,.css-173civf,.css-1nalx0p,.css-mn9570,.css-4r7szo,.css-vkey2q,.css-ugzr12,.css-6v1k3,.css-1xj1964,.css-ggid2,.css-rhbxt0,.css-1j23ebo`, /** 背景色透明的元素名称 */ cssNamesBackgroundTransparent: `.ContentItem-more:before`, cssNamesColorUserBackground1: ``, menuBeforeAfter: (color, size = "12px") => { return `background: radial-gradient(circle at top left, transparent ${size}, ${color} 0) top left, radial-gradient(circle at top right, transparent ${size}, ${color} 0) top right, radial-gradient(circle at bottom right, transparent ${size}, ${color} 0) bottom right, radial-gradient(circle at bottom left, transparent ${size}, ${color} 0) bottom left; background-size: 50% 50%; background-repeat: no-repeat;`; } }; var myCustomStyle = { init: async function() { const nodeCustomStyle = dom('[name="textStyleCustom"]'); if (!nodeCustomStyle) return; const { customizeCss = "" } = await myStorage.getConfig(); nodeCustomStyle.value = customizeCss; this.change(customizeCss); }, change: (innerCus) => fnInitDomStyle("CTZ_STYLE_CUSTOM", innerCus) }; var onUseThemeDark = async () => { const isD = await isDark(); dom("html").setAttribute("data-theme", isD ? "dark" : "light"); }; var loadFindTheme = () => { onUseThemeDark(); const elementHTML = dom("html"); const muConfig = { attribute: true, attributeFilter: ["data-theme"] }; if (!elementHTML) return; const muCallback = async function() { const themeName = elementHTML.getAttribute("data-theme"); const isD = await isDark(); if (themeName === "dark" && !isD || themeName === "light" && isD) { onUseThemeDark(); } }; const muObserver = new MutationObserver(muCallback); muObserver.observe(elementHTML, muConfig); }; var loadBackground = () => myBackground.init(); var isDark = async () => await myBackground.isUseDark(); var createItem = ({ label, value, background, color, inputName }) => ``; var createThemeHTML = (themeConfig, inputName) => { return Object.keys(themeConfig).map((key) => { const { background, color, name } = themeConfig[key]; return createItem({ label: name, value: key, background, color, inputName }); }).join(""); }; var addBackgroundElement = () => { domById("CTZ_BACKGROUND").innerHTML = THEMES.map((item) => createItem({ ...item, inputName: INPUT_NAME_THEME })).join(""); domById("CTZ_BACKGROUND_LIGHT").innerHTML = createThemeHTML(THEME_CONFIG_LIGHT, INPUT_NAME_ThEME_LIGHT); domById("CTZ_BACKGROUND_DARK").innerHTML = createThemeHTML(THEME_CONFIG_DARK, INPUT_NAME_THEME_DARK); }; var myMenu = { init: function() { const { hash } = location; const nodeMenuTop = dom(".ctz-menu"); if (!nodeMenuTop) return; const chooseId = [...nodeMenuTop.children].map((i) => i.hash).find((i) => i === hash || hash.replace(i, "") !== hash); this.click({ target: dom(`a[href="${chooseId || HEADER[0].href}"]`) }); }, /** 选择菜单 */ click: function({ target }) { const targetForA = target.tagName === "A" ? target : target.parentElement; if (!(targetForA.hash && targetForA.tagName === "A")) return; const chooseId = targetForA.hash.replace(/#/, ""); if (!chooseId) return; const nodesA = domA(".ctz-menu>a"); for (let i = 0, len = nodesA.length; i < len; i++) { nodesA[i].classList.remove("target"); } targetForA.classList.add("target"); const nodesDiv = domA(".ctz-content>div"); for (let i = 0, len = nodesDiv.length; i < len; i++) { const item = nodesDiv[i]; item.style.display = chooseId === item.id ? "flex" : "none"; } myMenu2.init(chooseId); } }; var myMenu2 = { init: function(chooseId) { const domContentTop = dom(`#${chooseId} .ctz-content-top`); if (!domContentTop || !domContentTop.children || !domContentTop.children.length) return; const { hash } = location; const target = [...domContentTop.children].find((i) => i.hash === hash); this.click({ target: target || domContentTop.children[0] }); }, click: function({ target }) { const chooseId = target.hash.replace(/#/, ""); if (!chooseId) return; const nodesA = target.parentElement.children; for (let i = 0, len = nodesA.length; i < len; i++) { nodesA[i].classList.remove("target"); } target.classList.add("target"); const nodesDiv = target.parentElement.parentElement.querySelectorAll(".ctz-content-center>div"); for (let i = 0, len = nodesDiv.length; i < len; i++) { const item = nodesDiv[i]; item.style.display = chooseId === item.id ? "block" : "none"; } } }; var positionOne = (position, max) => { if (position < 0) return 0; if (position > max) return max; return position; }; var openButtonPosition = async () => { const { openButtonTop, openButtonLeft } = await myStorage.getConfig(); const domFind = domById("CTZ_OPEN_BUTTON"); if (!domFind) return; const maxLeft = window.innerWidth - domFind.offsetWidth; const maxTop = window.innerHeight - domFind.offsetHeight; const innerLeft = positionOne(openButtonLeft, maxLeft); const innerTop = positionOne(openButtonTop, maxTop); domFind.style.cssText += `top: ${innerTop}px; left: ${innerLeft}px;`; let startX = 0; let startY = 0; let x = 0; let y = 0; domFind.addEventListener("touchstart", function(e) { startX = e.targetTouches[0].pageX; startY = e.targetTouches[0].pageY; x = this.offsetLeft; y = this.offsetTop; this.style.transition = ""; }); domFind.addEventListener("touchmove", function(e) { let moveX = e.targetTouches[0].pageX - startX; let moveY = e.targetTouches[0].pageY - startY; const left = x + moveX; const top = y + moveY; this.style.left = positionOne(left, maxLeft) + "px"; this.style.top = positionOne(top, maxTop) + "px"; e.preventDefault(); }); domFind.addEventListener("touchend", async function() { const left = this.offsetLeft > maxLeft / 2 ? maxLeft : 0; this.style.left = `${left}px`; this.style.transition = "all 0.5s"; const top = this.offsetTop; await myStorage.updateConfig({ openButtonTop: top, openButtonLeft: left }); }); }; var INNER_HTML = `
`; var INNER_CSS = `.hover-style{cursor:pointer}.hover-style:hover{color:#1677ff !important}.ctz-btn-box{display:flex}.ctz-btn-box button{flex:1;margin-right:12px}.ctz-btn-box button:last-child{margin:0}.ctz-desc,.ctz-commit{font-size:14px;color:#999}.ctz-desc b,.ctz-commit b{color:#e55353}.ctz-desc{padding-left:4px}.dis-if-c{display:inline-flex;align-items:center}.ta-c{text-align:center}.fwb{font-weight:bold}.mt8{margin-top:8px}.bg-ec7259{background:#ec7259}.bg-12c2e9{background:#12c2e9}.bg-00965e{background:#00965e}.bg-9c27b0{background:#9c27b0}.c-ec7259{color:#ec7259}.c-12c2e9{color:#12c2e9}.c-00965e{color:#00965e}.c-9c27b0{color:#9c27b0}.ctz-button{outline:none;position:relative;display:inline-block;font-weight:400;white-space:nowrap;text-align:center;border:1px solid transparent;cursor:pointer;transition:all .3s;user-select:none;touch-action:manipulation;line-height:1.5;font-size:14px;height:32px;padding:4px 15px;border-radius:6px;background-color:#ffffff;border-color:#d9d9d9;color:rgba(0,0,0,0.88);box-shadow:0 2px 0 rgba(0,0,0,0.02)}.ctz-button:hover{color:#1677ff;border-color:#1677ff}.ctz-button:active{background:rgba(0,0,0,0.08) !important}.ctz-button[size='small'],.ctz-button.ctz-button-small{padding:2px 6px;font-size:12px;height:24px}.ctz-button.ctz-button-transparent{background:transparent}.ctz-button-red{color:#e55353 !important;border:1px solid #e55353 !important}.ctz-button-red:hover{color:#ec7259 !important;border:1px solid #ec7259 !important}.ctz-button:disabled{border-color:#d0d0d0;background-color:rgba(0,0,0,0.08);color:#b0b0b0;cursor:not-allowed}[name='buttonHistoryClear']{margin-bottom:12px}#CTZ_BACKGROUND,#CTZ_BACKGROUND_LIGHT,#CTZ_BACKGROUND_DARK{display:grid;gap:8px}#CTZ_BACKGROUND>label,#CTZ_BACKGROUND_LIGHT>label,#CTZ_BACKGROUND_DARK>label{position:relative;cursor:pointer}#CTZ_BACKGROUND>label input,#CTZ_BACKGROUND_LIGHT>label input,#CTZ_BACKGROUND_DARK>label input{position:absolute;pointer-events:none;width:20px;height:20px;top:18px;left:20px}#CTZ_BACKGROUND>label input:checked+div,#CTZ_BACKGROUND_LIGHT>label input:checked+div,#CTZ_BACKGROUND_DARK>label input:checked+div{border:4px solid #1677ff}#CTZ_BACKGROUND>label div,#CTZ_BACKGROUND_LIGHT>label div,#CTZ_BACKGROUND_DARK>label div{pointer-events:none;border:4px double #eee;font-size:14px;border-radius:12px;line-height:56px;padding-left:60px}#CTZ_BACKGROUND_LIGHT{color:#000}.ctz-set-background{margin:-12px}.ctz-set-background .ctz-background-title{padding:12px 12px 0}.ctz-set-background .ctz-background-content{padding:12px;border-bottom:1px solid #d9d9d9}.ctz-set-background .ctz-background-content:last-of-type{border:none}@font-face{font-family:'tp-icon';src:url('//at.alicdn.com/t/c/font_2324733_3w6h6fk5917.woff2?t=1670580424651') format('woff2'),url('//at.alicdn.com/t/c/font_2324733_3w6h6fk5917.woff?t=1670580424651') format('woff'),url('//at.alicdn.com/t/c/font_2324733_3w6h6fk5917.ttf?t=1670580424651') format('truetype')}.ctz-icon{font-family:'tp-icon' !important;font-size:16px;font-style:normal;-webkit-font-smoothing:antialiased;-webkit-text-stroke-width:.2px;-moz-osx-font-smoothing:grayscale}.ctz-stop-scroll{height:100% !important;overflow:hidden !important}#CTZ_OPEN_BUTTON{position:fixed;font-size:34px;background:#e1e1e1;color:#000;opacity:.6;width:48px;height:48px;line-height:48px;border-radius:8px;z-index:2000;text-align:center}#CTZ_DIALOG{position:fixed;top:0;left:0;width:100%;height:100%;background:#f5f5f5;z-index:2001;font-size:16px;transition:all .2s;flex-direction:column}#CTZ_DIALOG input[type='checkbox']{width:16px;height:16px}#CTZ_DIALOG textarea{box-sizing:border-box;margin:0;padding:4px 11px;font-size:14px;line-height:1.5;list-style:none;position:relative;display:inline-block;min-width:0;border-width:1px;border-style:solid;border-color:#d9d9d9;border-radius:6px;transition:all .2s}#CTZ_DIALOG a{color:inherit}.ctz-header{font-size:16px;display:flex;align-items:center;height:48px;padding:0 12px}.ctz-top-operate{flex:1;padding:0 12px;font-size:12px}.ctz-version{font-size:16px}#CTZ_CLOSE_DIALOG{font-weight:bold;width:40px;height:40px;color:rgba(0,0,0,0.45);background:transparent;border:none}#CTZ_CLOSE_DIALOG i{font-size:12px}.ctz-menu{height:36px;display:flex}.ctz-menu>a{border-radius:12px 12px 0 0;flex:1;text-align:center;cursor:pointer;transition:initial !important;position:relative;display:flex;align-items:center;justify-content:center}.ctz-menu>a span{border-radius:8px;transition:all .3s;margin:0 4px;flex:1;box-sizing:border-box;align-items:center;line-height:26px}.ctz-menu>a.target{background:#fff}.ctz-menu>a.target::after,.ctz-menu>a.target::before{position:absolute;bottom:-12px;content:' ';background:radial-gradient(circle at top left, transparent 12px, #fff 0) top left,radial-gradient(circle at top right, transparent 12px, #fff 0) top right,radial-gradient(circle at bottom right, transparent 12px, #fff 0) bottom right,radial-gradient(circle at bottom left, transparent 12px, #fff 0) bottom left;background-size:50% 50%;background-repeat:no-repeat;width:24px;height:24px}.ctz-menu>a.target::before{left:-12px;z-index:-1}.ctz-menu>a.target::after{right:-12px;z-index:-1}.ctz-content{flex:1;overflow:hidden;background:#fff;border-radius:12px;padding:8px 0}.ctz-content>div{height:100%;flex-direction:column}.ctz-content-top{height:28px;display:flex;padding-bottom:8px}.ctz-content-top a{flex:1;text-align:center;line-height:28px;margin:0 8px;border-radius:8px}.ctz-content-top a.target{background-color:#f5f5f5}.ctz-content-top~.ctz-content-center{padding-top:0}.ctz-content-center{flex:1;overflow-y:auto;padding:12px}.ctz-content-center ::-webkit-scrollbar{width:8px;height:8px}.ctz-content-center ::-webkit-scrollbar-track{border-radius:0}.ctz-content-center ::-webkit-scrollbar-thumb{background:#bbb;transition:all .2s;border-radius:8px}.ctz-content-center ::-webkit-scrollbar-thumb:hover{background-color:rgba(95,95,95,0.7)}.ctz-hidden-item-br{margin:12px 0;width:100%;height:1px;position:relative}.ctz-hidden-item-br::after{content:'';position:absolute;top:0;left:50%;transform:translateX(-50%);width:65%;height:1px;background:#d9d9d9}#CTZ_HIDDEN .ctz-content-center label{margin-right:12px;margin-bottom:4px}#CTZ_BASIS_SHOW label{margin:8px 0}#CTZ_BASIS_SHOW label b{display:inline-block;padding:0 4px;background:#f5f5f5;border-radius:2px;margin-right:2px}.ctz-suspension-pickup{position:fixed;bottom:60px;right:14px;text-align:center;height:40px;line-height:40px;width:68px;border-radius:4px;font-size:14px;background:#fff}.ctz-label{font-size:14px;line-height:24px}.ctz-label::after{content:':'}.ctz-flex-wrap{display:flex;flex-wrap:wrap;line-height:24px}.ctz-flex-wrap label{margin-right:4px;display:flex;align-items:center}.ctz-flex-wrap label input[type='radio']{margin:0 4px 0 0}.ctz-label-tag{font-weight:normal;padding:2px 4px;border-radius:4px;font-size:12px;color:#ffffff;margin:0 2px}.ctz-label-tag-Answer{background:#ec7259}.ctz-label-tag-ZVideo{background:#12c2e9}.ctz-label-tag-Article{background:#00965e}.ctz-label-tag-Pin{background:#9c27b0}#CTZ_HISTORY_LIST .ctz-set-content a,#CTZ_HISTORY_VIEW .ctz-set-content a{word-break:break-all;display:block;margin-bottom:12px;padding:6px 12px;border:1px solid #eee;border-radius:4px}.ctz-fetch-intercept .ctz-need-fetch{display:none}.ctz-fetch-intercept.ctz-fetch-intercept-close{color:#b0b0b0 !important;cursor:not-allowed}.ctz-fetch-intercept.ctz-fetch-intercept-close span.ctz-need-fetch{display:inline}.ctz-fetch-intercept.ctz-fetch-intercept-close div.ctz-need-fetch{display:block}.ctz-fetch-intercept.ctz-fetch-intercept-close .ctz-remove-block{cursor:not-allowed !important}.ctz-fetch-intercept.ctz-fetch-intercept-close .ctz-black-item .ctz-remove-block:hover,.ctz-fetch-intercept.ctz-fetch-intercept-close .ctz-black-item a:hover{background:transparent !important;color:#b0b0b0 !important}#CTZ_MESSAGE_BOX{position:fixed;left:0;top:10px;width:100%;z-index:2002}.ctz-message{margin:20px auto;width:70%;height:48px;display:flex;align-items:center;justify-content:center;font-size:14px;border-radius:8px;box-shadow:0 0 8px #d0d4d6,0 0 8px #e6eaec;margin-bottom:12px;background:#fff}.ctz-config-import-box{display:flex;flex-direction:column}.ctz-config-import-box>div,.ctz-config-import-box>textarea{margin-bottom:12px !important}.ctz-config-import-box textarea{height:120px;resize:vertical}`; var INNER_VERSION = `1.1.0`; var initHTML = () => { document.body.appendChild(domC("div", { id: "CTZ_MAIN", innerHTML: INNER_HTML })); openButtonPosition(); dom(".ctz-version").innerText = `version: ${INNER_VERSION}`; dom(".ctz-menu").innerHTML = HEADER.map(({ href, value }) => `${value}`).join(""); addBackgroundElement(); dom("#CTZ_HIDDEN .ctz-content-center").innerHTML = HIDDEN_ARRAY.map( (itemArr) => itemArr.map(({ label, value }) => ``).join("") + '' ).join(""); dom("#CTZ_BASIS_SHOW").innerHTML += BASIC_SHOW_CONTENT.map( ({ label, value, needFetch }) => `` ).join(""); myMenu.init(); }; var fnHiddenDom = (lessNum, ev, log) => { ev.style.display = "none"; fnLog(log); return ++lessNum; }; var fnIndexMath = (index, i, len, lessNum) => { return i + 1 === len ? i - lessNum >= 0 ? i - lessNum : 0 : index; }; var CLASS_COPY_LINK = "ctz-copy-answer-link"; var addAnswerCopyLink = async (nodeItem) => { const { copyAnswerLink } = await myStorage.getConfig(); if (!copyAnswerLink) return; const prevButton = nodeItem.querySelector(`.${CLASS_COPY_LINK}`); prevButton && prevButton.remove(); const nodeUser = nodeItem.querySelector(".AnswerItem-authorInfo>.AuthorInfo") || nodeItem.querySelector(".ContentItem-meta"); if (!nodeUser) return; const nDomButton = createBtnTr("获取链接", CLASS_COPY_LINK); nDomButton.onclick = function() { const metaUrl = nodeItem.querySelector('.ContentItem>[itemprop="url"]'); if (!metaUrl) return; const link = metaUrl.getAttribute("content") || ""; if (link) { copy(link); message("链接复制成功"); return; } }; nodeUser.appendChild(nDomButton); }; var timeFormatter = (time, formatter = "YYYY-MM-DD HH:mm:ss") => { if (!time) return ""; const date = new Date(time); const year = date.getFullYear(); const month = date.getMonth() + 1; const day = date.getDate(); const hour = date.getHours(); const min = date.getMinutes(); const sec = date.getSeconds(); const preArr = (num) => String(num).length !== 2 ? "0" + String(num) : String(num); return formatter.replace(/YYYY/g, String(year)).replace(/MM/g, preArr(month)).replace(/DD/g, preArr(day)).replace(/HH/g, preArr(hour)).replace(/mm/g, preArr(min)).replace(/ss/g, preArr(sec)); }; var updateItemTime = (event) => { const nodeCreated = event.querySelector('[itemprop="dateCreated"]'); const nodePublished = event.querySelector('[itemprop="datePublished"]'); const nodeModified = event.querySelector('[itemprop="dateModified"]'); const crTime = nodeCreated ? nodeCreated.content : ""; const puTime = nodePublished ? nodePublished.content : ""; const muTime = nodeModified ? nodeModified.content : ""; const timeCreated = timeFormatter(crTime || puTime); const timeModified = timeFormatter(muTime); const nodeContentItemMeta = event.querySelector(".ContentItem-meta"); if (!timeCreated || !nodeContentItemMeta) return; const innerHTML = `