// ==UserScript==
// @name 【移动端】百度系优化
// @namespace https://github.com/WhiteSevs/TamperMonkeyScript
// @version 2025.10.28
// @author WhiteSevs
// @description 用于【移动端】的百度系列产品优化,包括【百度搜索】、【百家号】、【百度贴吧】、【百度文库】、【百度经验】、【百度百科】、【百度知道】、【百度翻译】、【百度图片】、【百度地图】、【百度好看视频】、【百度爱企查】、【百度问题】、【百度识图】等
// @license GPL-3.0-only
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAABZlJREFUeF7VW+1x2zAMhdpkjjobeIM2kzT+HfeuG6TeoHdNfsedpM4G3iDpHO1VDUjJIimC+CB1bvXTlkTwEQQeHqEOFrrWn/ob6OEjAHyAHl6ggxcA2B3vu8NCQ5pe25meKjy0/tyv4Dc8uonnrg42x2/dXjvuAOjq9b2HliC2B2Db/yAnP85aAcI6/74DXMDm+LVDr6q6mgKw3vZfAOBOZNEFXJUmwHoSDsK8Q2JHMwAGg58lgw73YDxAwLIXsfLzeytBaAeAZvXHaRDGqzzJB1YSSG5B2gFw2z++RvobbsDo/wwABk8CUMSU1L52AEiC33z0WUZQrr5/Yw/740O3UYE/3NwSgF5tQLJyptX3ALwcH7or9fivxKQJABWGRyu33vbIHTCNqq/jfWeai+mhnHXr2/4ZOkCiIr8S1zW5/7/gAWiDCYAkgv/fAFiCIMB1SGvXlkzi/Q3p8bXc9aY7W24BdRpM9+3A97GO0F5mLiACYAhOziiqEFEHsEzkNgFQkQFwPkUAnEtiVRcGN1/afocL2KdcXhkHZqtmzCbm1S8CIODis4rMeUEPuBXK2aCwaioQK1efBEAcjdEbLuE69AT2WcZo5VaKgqg2cGQBMLjh3JWxMEI1aO4JqAaxqhALorfcJKykIM1igGjwOdSzlRiAxOLovZPE3sCTRgkqbCcSRBdEPTFaOQkOvY2R4CIADKvvoagoRji3HWzCCa3gLRxyIgoTew4YtCnwYwC8kGnJw5geRSmVm7D2f3Hq7GEPl7BLAYwBsIgao8WVyox24o5+ewG2SoVKAeAFTcrScwBgoc6JnTEAlhee0wO2vV6DSOJVMwAsMcC58HBpJW6D+0++G3hBmxigYGQuaP2BuyxHKETrdOcZ07V/DQmAPQuw5aiAWo9zFB16VAEQkKg5EbIoO4w0rZj8yCuQOO1KxKlCO4hYZBMmSO1/0elOKf8VMstiALj8qvMCshxVr3wKRqbYGm+pAiBQorLsza3cL/jBlrUFKapqj4ZAECCIGWDGw0KPJelrkV97UWRDqkN6hsYRwVzFaZPQk4zF8vehPkeh4x1WdGhpMTjJvYebdPr/HATdVh3fF72HBUBrZfW+Lw8YGW+KAyUqrJ1shpyUaom0NSbfQcIZEUxAEauyq48/NvMAZjUiolRFY5OgqAAhS9aaACBw+3YA4LLltMixKcurQZMoizoAUmxCGaoGQDB5NHmG/tpSycXbQ0SZuR1lBkDJ8pYAwAFb2yxlAkA5+aU8YKobEmmeW/XwfzUAQt0+jfhPaR9Pgy0wzaNAmTkwVAAUJ++l72IFFxoTAHBwQW264qO48XcMZgMRcz+NXajxcqrPCsQAMCvP6gEZzuDlrISYkOk0baehBFzlgYkIgGLeNp4JnDygNQAeafGBqQwAqvmBkMJOhxnBsqd5eGEAxCCwADBlba5AyTVK0GlwGQ/w0Auk+nJ/QKmszTU40Acr5wFA0DpTBqB0UpQHgNLpzwUA6wUcAHR1lwDAFDjnA4AJiBwA9MlLCkC5yfGcABRTNC2JcbJWbgvQCs35AGAObeweoCExpWpwySwwlM6lPuIyALzmFktUtB4o9wDq6EzKBFPKWekB/HF5rucf40HSWkcSIYK6hr2JOKfM89LPc2wxAAcVafvGSiw4fDHV9CLbBLSYJ0KSAxIDCMnp0y7XeFkqZaUAcMf2PBXWNU24hqSkvKXmkX4XgBoCnjvIPqz0bXjcJzpsUcQDsNxBB6dV1P9fWwuMFjh3yzc+1hu53BvY1cehWQ8IQJD1AS83Ic2bxQKNGACXFVpsB5S2xquDn8GssKM01vQ1U57uFa38ZIJhkNOBqW+DnXeGD22q7tWjjkd0eabDB2IKHp1pQFFnEtUWMODU7JETKUJyNQLuP8f3n8xVfJL/F9CfBX10dPIcAAAAAElFTkSuQmCC
// @supportURL https://github.com/WhiteSevs/TamperMonkeyScript/issues
// @match *://*.baidu.com/*
// @match *://www.tieba.com/*
// @match *://jump2.bdimg.com/*
// @match *://uf9kyh.smartapps.cn/*
// @require https://fastly.jsdelivr.net/gh/WhiteSevs/TamperMonkeyScript@86be74b83fca4fa47521cded28377b35e1d7d2ac/lib/CoverUMD/index.js
// @require https://fastly.jsdelivr.net/gh/WhiteSevs/TamperMonkeyScript@86be74b83fca4fa47521cded28377b35e1d7d2ac/lib/showdown/index.js
// @require https://fastly.jsdelivr.net/npm/@whitesev/utils@2.9.6/dist/index.umd.js
// @require https://fastly.jsdelivr.net/npm/@whitesev/domutils@1.7.4/dist/index.umd.js
// @require https://fastly.jsdelivr.net/npm/@whitesev/pops@2.6.1/dist/index.umd.js
// @require https://fastly.jsdelivr.net/npm/qmsg@1.5.1/dist/index.umd.js
// @require https://fastly.jsdelivr.net/npm/viewerjs@1.11.7/dist/viewer.min.js
// @require https://fastly.jsdelivr.net/npm/vue@3.5.22/dist/vue.global.prod.js
// @require https://fastly.jsdelivr.net/npm/vue-demi@0.14.10/lib/index.iife.min.js
// @require https://fastly.jsdelivr.net/npm/pinia@3.0.3/dist/pinia.iife.prod.js
// @require https://fastly.jsdelivr.net/npm/vue-router@4.6.3/dist/vue-router.global.js
// @require https://fastly.jsdelivr.net/gh/WhiteSevs/TamperMonkeyScript@70fca3b5fc45d132c7d8a73d1d94e014a3892c5d/lib/Element-Plus/index.js
// @require https://fastly.jsdelivr.net/npm/@element-plus/icons-vue@2.3.2/dist/index.iife.min.js
// @resource ElementPlusResourceCSS https://fastly.jsdelivr.net/npm/element-plus@2.11.5/dist/index.min.css
// @resource ViewerCSS https://fastly.jsdelivr.net/npm/viewerjs@1.11.7/dist/viewer.min.css
// @connect *
// @connect www.baidu.com
// @connect m.baidu.com
// @connect tieba.baidu.com
// @connect www.tieba.com
// @connect baike.baidu.com
// @connect chat.baidu.com
// @connect chat-ws.baidu.com
// @connect wappass.baidu.com
// @connect tiebaswan.baidu.com
// @grant GM_addStyle
// @grant GM_deleteValue
// @grant GM_getResourceText
// @grant GM_getValue
// @grant GM_info
// @grant GM_listValues
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_setValues
// @grant GM_unregisterMenuCommand
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @run-at document-start
// ==/UserScript==
(function (Qmsg, DOMUtils, Utils, pops, vue, Viewer, pinia, iconsVue, vueDemi, vueRouter, ElementPlus) {
"use strict";
const d = new Set();
const importCSS = async (t) => {
d.has(t) ||
(d.add(t),
((a) => {
function r(n) {
if (typeof GM_addStyle == "function") return GM_addStyle(n);
const e = document.createElement("style");
if ((e.setAttribute("type", "text/css"), e.setAttribute("data-type", "gm-css"), globalThis.trustedTypes)) {
const c = globalThis.trustedTypes.createPolicy("safe-innerHTML", { createHTML: (i) => i });
e.innerHTML = c.createHTML(n);
} else e.innerHTML = n;
return ((document.head || document.documentElement).appendChild(e), e);
}
r(a);
})(t));
};
importCSS(
' @charset "UTF-8";#small-toolbar[data-v-b2773fdf]{position:fixed;bottom:0;width:100%;background:#fff;height:.56rem;display:flex;align-items:center;z-index:1000}#small-toolbar .icon[data-v-b2773fdf]{width:.2rem;height:.2rem}#small-toolbar #reply-editor[data-v-b2773fdf]{flex:1}#small-toolbar .small-editor-toolbar[data-v-b2773fdf]{flex:1;margin:10px 15px;width:100%;font-size:.16rem;line-height:.16rem;display:flex;align-items:center;position:relative}#small-toolbar .small-editor-toolbar .small-editor-toolbar-input[data-v-b2773fdf]{width:100%;background:#e9e9e9;border-radius:.06rem;padding:.06rem;border:0;outline:none;font-size:.14rem;line-height:.14rem;cursor:default}#small-toolbar .small-editor-toolbar .small-editor-toolbar-emoji-btn[data-v-b2773fdf]{position:absolute;top:50%;right:.06rem;transform:translateY(-50%)}#small-toolbar .small-editor-toolbar .small-editor-toolbar-input[data-v-b2773fdf]:focus,#small-toolbar .small-editor-toolbar .small-editor-toolbar-input[data-v-b2773fdf]:visited,#small-toolbar .small-editor-toolbar .small-editor-toolbar-input[data-v-b2773fdf]:focus-within,#small-toolbar .small-editor-toolbar .small-editor-toolbar-input[data-v-b2773fdf]:focus-visible{border:0;outline:none}#small-toolbar .gm-reply-other-toolbar[data-v-b2773fdf]{flex:0 auto;display:flex;align-items:safe center}#small-toolbar .gm-reply-other-toolbar .reply-comment-count[data-v-b2773fdf],#small-toolbar .gm-reply-other-toolbar .reply-good-count[data-v-b2773fdf]{padding:8px;display:flex;flex-direction:column;align-items:center}#small-toolbar .gm-reply-other-toolbar .reply-comment-count p.text[data-v-b2773fdf],#small-toolbar .gm-reply-other-toolbar .reply-good-count p.text[data-v-b2773fdf]{font-size:.1rem}.tiptap p.is-editor-empty:first-child:before{content:attr(data-placeholder);float:left;color:#adb5bd;pointer-events:none;height:0}#reply-editor .tiptap{width:100%;height:100%;outline:0!important;font-size:.16rem}.tiptap-input-image{width:.18rem;height:.18rem}#reply-editor[data-v-661335ab]{overflow:auto;background-color:#e5e5e5;padding:.06rem;height:100%;border-radius:5px}.icon-active[data-v-6550ea22]{fill:#7557ff}#full-toolbar[data-v-6550ea22]{position:fixed;bottom:0;width:100%;background:#fff;display:flex;align-items:center;z-index:100099;flex-flow:column}#full-toolbar .full-toolbar-top-reply-user[data-v-6550ea22]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#adb5bd;width:-webkit-fill-available;width:-moz-available;padding-left:.2rem;padding-top:.06rem}#full-toolbar .full-toolbar-top-container[data-v-6550ea22]{display:flex;align-items:end;width:-moz-available;width:-webkit-fill-available;padding:.06rem .1rem;height:.6rem}#full-toolbar .full-toolbar-top-container .full-toolbar-top-left-container[data-v-6550ea22]{display:flex;flex-direction:column;flex:1;overflow:hidden;margin:0px .1rem;height:100%}#full-toolbar .full-toolbar-top-container .full-toolbar-top-right-container[data-v-6550ea22]{flex:0 auto;display:flex;flex-direction:column;align-items:center;justify-content:space-between;height:100%}#full-toolbar .full-toolbar-bottom-container[data-v-6550ea22]{margin:.06rem 0;padding:0px 0px .06rem;margin-right:auto}#full-toolbar .full-toolbar-bottom-container .full-toolbar-emoji-btn[data-v-6550ea22],#full-toolbar .full-toolbar-bottom-container .full-toolbar-panel-at-btn[data-v-6550ea22]{margin:0 20px;display:flex;flex-direction:column;align-items:center}#full-toolbar .emoji-panel[data-v-6550ea22]{width:100%;height:30vh;background-color:#efefef;overflow:auto}.emoji-panel-huaji[data-v-6550ea22]{padding:.03rem;overflow-y:auto}.emoji-panel-huaji .el-avatar[data-v-6550ea22]{margin:16px}#full-toolbar[data-v-6550ea22]:has(.full-toolbar-top-container[data-full=true]){height:-moz-available;height:100%;height:-webkit-fill-available}#full-toolbar:has(.full-toolbar-top-container[data-full=true]) .full-toolbar-top-container[data-v-6550ea22],#full-toolbar:has(.full-toolbar-top-container[data-full=true]) #reply-editor[data-v-6550ea22]{height:-moz-available;height:100%;height:-webkit-fill-available}#full-toolbar:has(.full-toolbar-top-container[data-full=true]) .full-toolbar-top-reply-user[data-v-6550ea22],#full-toolbar:has(.full-toolbar-top-container[data-full=true]) .full-toolbar-top-right-container[data-v-6550ea22]{display:none}#full-toolbar:has(.full-toolbar-top-container[data-full=true]) .full-toolbar-top-container[data-v-6550ea22]{flex-direction:column}#full-toolbar:has(.full-toolbar-top-container[data-full=true]) .full-toolbar-top-left-container[data-v-6550ea22]{width:-webkit-fill-available;width:-moz-available}.full-toolbar-top-nav-container[data-v-6550ea22]{display:flex;width:-webkit-fill-available;width:-moz-available;align-items:center;justify-content:space-between;padding:.16rem}#full-toolbar .full-toolbar-top-container{max-height:calc(100vh - .12rem - 40px)}#full-toolbar[data-show-bottom-panel=true] .full-toolbar-top-container{max-height:calc(70vh - .12rem - 40px)}.posts-container-item[data-v-3116157a]{width:-webkit-fill-available;width:-moz-available}.posts-item-title[data-v-3116157a]{font-weight:700}.posts-item-title[data-v-3116157a],.posts-item-content[data-v-3116157a],.posts-item-media-container[data-v-3116157a]{margin:10px 0}.posts-item-footer[data-v-3116157a]{margin:15px 0 5px}.posts-item-footer .el-col[data-v-3116157a]{text-align:center}.posts-item-footer-icon-container[data-v-3116157a]{display:flex;align-items:center;justify-content:center;gap:0px 6px}.posts-item-right-user-info[data-v-3116157a]{padding:0 10px}.posts-container[data-v-41f50a7a]{background:#f2f2f4;padding:10px}.posts-container-item[data-v-41f50a7a]{background:#fff;border-radius:12px;margin:10px 0;padding:10px}.posts-item-title[data-v-41f50a7a]{font-weight:700}.posts-item-title[data-v-41f50a7a],.posts-item-content[data-v-41f50a7a],.posts-item-media-container[data-v-41f50a7a]{margin:10px 0}.posts-item-footer[data-v-41f50a7a]{margin:15px 0 5px}.posts-item-footer .el-col[data-v-41f50a7a]{text-align:center}.posts-item-footer-icon-container[data-v-41f50a7a]{display:flex;align-items:center;justify-content:center;gap:0px 6px}.posts-item-right-user-info[data-v-41f50a7a]{padding:0 10px}.follow-forum-container[data-v-9f65e55d]{background:#f2f2f4;padding:10px}.follow-forum-list-container[data-v-9f65e55d]{background:#fff;border-radius:12px;margin:10px 0;padding:10px}.follow-forum-item[data-v-9f65e55d]{width:50%;max-width:50%;display:flex;align-items:flex-start;margin:10px 0}.follow-forum-avatar[data-v-9f65e55d]{border-radius:12px}.follow-forum-item-right-container[data-v-9f65e55d]{margin:0 10px;width:inherit;display:flex;flex-direction:column}.follow-forum-item-name[data-v-9f65e55d]{display:flex;align-items:center;width:-webkit-fill-available;width:-moz-available}.follow-forum-item-level[data-level][data-v-9f65e55d]{margin:5px;padding:2px;border-radius:3px;font-size:.6rem;line-height:.6rem;font-weight:700;text-align:center;background:var(--v0ae5f27b);color:var(--v384f0200)}.follow-forum-item-level[data-level="0"][data-v-9f65e55d],.follow-forum-item-level[data-level="1"][data-v-9f65e55d],.follow-forum-item-level[data-level="2"][data-v-9f65e55d],.follow-forum-item-level[data-level="3"][data-v-9f65e55d]{background:var(--b2383e38)}.follow-forum-item-level[data-level="4"][data-v-9f65e55d],.follow-forum-item-level[data-level="5"][data-v-9f65e55d],.follow-forum-item-level[data-level="6"][data-v-9f65e55d],.follow-forum-item-level[data-level="7"][data-v-9f65e55d],.follow-forum-item-level[data-level="8"][data-v-9f65e55d],.follow-forum-item-level[data-level="9"][data-v-9f65e55d]{background:var(--b2382024)}.follow-forum-item-level[data-level="10"][data-v-9f65e55d],.follow-forum-item-level[data-level="11"][data-v-9f65e55d],.follow-forum-item-level[data-level="12"][data-v-9f65e55d],.follow-forum-item-level[data-level="13"][data-v-9f65e55d],.follow-forum-item-level[data-level="14"][data-v-9f65e55d],.follow-forum-item-level[data-level="15"][data-v-9f65e55d]{background:var(--v7d689d44)}.follow-forum-item-level[data-level="16"][data-v-9f65e55d],.follow-forum-item-level[data-level="17"][data-v-9f65e55d],.follow-forum-item-level[data-level="18"][data-v-9f65e55d]{background:var(--v7d6b5781)}.follow-forum-item-info[data-v-9f65e55d]{word-wrap:break-word}#main[data-v-0eef167d]{z-index:1000;width:100%;height:100%}.big-text[data-v-0eef167d]{font-weight:700}.top-container[data-v-0eef167d]{width:-webkit-fill-available;width:-moz-available;padding:15px 15px 0}.user-info-bg[data-v-0eef167d]{width:100%;height:100px}.user-info-bg-main[data-v-0eef167d]{width:100%;height:160px;position:absolute;background:url(https://tb2.bdstatic.com/tb/mobile/suser/img/home_card_back_6cdfca5.jpg);background-size:100%;background-repeat:no-repeat}.user-avatar-top-background[data-v-0eef167d]{position:absolute;width:100%;height:40%;padding:0;margin:0;border-top-left-radius:12px;border-top-right-radius:12px;background:#fff;transform:translateY(100%)}.user-info-container[data-v-0eef167d]{padding:0 10px}.nav-left-arrow-icon[data-v-9d6dd989]{align-content:center;padding-left:0!important}.nav-title[data-v-9d6dd989]{font-weight:700;text-align:center;padding:10px}.user-avatar[data-v-9d6dd989]{text-align:center;padding-bottom:20px}.user-info-item[data-v-9d6dd989]{display:flex;padding:10px;flex-wrap:wrap}.user-desc-key[data-v-9d6dd989]{width:60px;display:block}.user-end-text[data-v-9d6dd989]{padding:0 20px}.user-top[data-v-783d336f]{height:40px;width:100%;position:relative}.top-left-arrow-icon[data-v-783d336f]{align-content:center;padding-left:0!important}.top-title-name[data-v-783d336f]{text-align:center;padding:10px}.user-main[data-v-783d336f]{padding:0;position:absolute;inset:40px 0 0;width:100%;height:calc(100% - 40px)}.user-container[data-v-783d336f]{padding:0 10px}.user-container .el-scrollbar__view[data-v-783d336f]{height:100%}.user-item[data-v-783d336f]{margin:10px 0}.user-item-row[data-v-783d336f]{display:flex;align-items:center;justify-content:space-between}.user-item-row-center[data-v-783d336f]{padding:0 10px}.user-name[data-v-783d336f],.user-sign-text[data-v-783d336f]{text-align:left}.user-sign-text[data-v-783d336f]{color:#a2a2a2}.user-follow-btn[data-v-783d336f]{float:right}.user-info[data-v-783d336f]{display:grid}.user-item-row-left[data-v-783d336f]{display:flex}.user-item-row-right[data-v-783d336f]{float:right}.user-top[data-v-b315e76a]{height:40px;width:100%;position:relative}.top-left-arrow-icon[data-v-b315e76a]{align-content:center;padding-left:0!important}.top-title-name[data-v-b315e76a]{text-align:center;padding:10px}.user-main[data-v-b315e76a]{padding:0;position:absolute;inset:40px 0 0;width:100%;height:calc(100% - 40px)}.user-container[data-v-b315e76a]{padding:0 10px}.user-container .el-scrollbar__view[data-v-b315e76a]{height:100%}.user-item[data-v-b315e76a]{margin:10px 0}.user-item-row[data-v-b315e76a]{display:flex;align-items:center;justify-content:space-between}.user-item-row-center[data-v-b315e76a]{padding:0 10px;align-content:center}.user-name[data-v-b315e76a],.user-sign-text[data-v-b315e76a]{text-align:left}.user-sign-text[data-v-b315e76a]{color:#a2a2a2}.user-follow-btn[data-v-b315e76a]{float:right}.user-info[data-v-b315e76a]{display:grid}.user-item-row-left[data-v-b315e76a]{display:flex}.user-item-row-right[data-v-b315e76a]{float:right}.router-view-container[data-v-8524ef32]{padding:20px}.router-view-container .layout-item[data-v-8524ef32]{display:flex;align-items:center;gap:10px;padding:10px 0}.router-view-container .layout-icon img[data-v-8524ef32]{width:100%;height:100%}.router-view-container .layout-text[data-v-8524ef32]{flex:1}.post-list-item[data-v-552236f6]{display:flex;flex-direction:column;gap:10px;padding:10px 15px;border-bottom:5px solid #efefef}.post-list-item[data-v-552236f6]:last-child{border-bottom:0}.user-info[data-v-552236f6]{display:flex;align-items:center;gap:5px}.user-time[data-v-552236f6]{font-size:.8em;color:#999}.user-avatar img[data-v-552236f6]{width:35px;height:35px;border-radius:50%}.reply-content[data-v-552236f6]{font-size:.9em;color:#4a4a4a}.post-info[data-v-552236f6]{display:flex;align-items:center;background-color:#efefef;color:#434343;border-radius:6px}.post-info__inner[data-v-552236f6]{display:flex;align-items:center;height:100px;width:100%}.post-content[data-v-552236f6]{overflow:hidden;line-clamp:2;-webkit-line-clamp:2;display:-webkit-box;-webkit-box-orient:vertical;color:#545454;margin-left:5px}.post-image[data-v-552236f6]{width:100px;height:100px}.post-image img[data-v-552236f6]{width:inherit;height:inherit;border-radius:6px}.fname-text[data-v-552236f6]{color:#999}.bottom-msg[data-v-552236f6]{text-align:center;color:#999;padding:10px 0}.post-list-item[data-v-2b71b42f]{display:flex;flex-direction:column;gap:10px;padding:10px 15px;border-bottom:5px solid #efefef}.post-list-item[data-v-2b71b42f]:last-child{border-bottom:0}.user-info[data-v-2b71b42f]{display:flex;align-items:center;gap:5px}.user-time[data-v-2b71b42f]{font-size:.8em;color:#999}.user-avatar img[data-v-2b71b42f]{width:35px;height:35px;border-radius:50%}.reply-content[data-v-2b71b42f]{font-size:.9em;color:#4a4a4a}.post-info[data-v-2b71b42f]{display:flex;align-items:center;background-color:#efefef;color:#434343;border-radius:6px}.post-info__inner[data-v-2b71b42f]{display:flex;align-items:center;height:100px;width:100%}.post-content[data-v-2b71b42f]{overflow:hidden;line-clamp:2;-webkit-line-clamp:2;display:-webkit-box;-webkit-box-orient:vertical;color:#545454;margin-left:5px}.post-info[data-v-2b71b42f]:has(.quote-user){flex-direction:column;align-items:start;padding:10px;gap:10px}.post-info:has(.quote-user) .post-content[data-v-2b71b42f]{flex:1;align-content:center;padding:0 10px;margin-left:0;background:#fff;height:inherit}.post-image[data-v-2b71b42f]{width:100px;height:100px}.post-image img[data-v-2b71b42f]{width:inherit;height:inherit;border-radius:6px}.fname-text[data-v-2b71b42f]{color:#999}.bottom-msg[data-v-2b71b42f],.bottom-msg[data-v-b2e309d0]{text-align:center;color:#999;padding:10px 0}.user-top[data-v-21d9b8e4]{--el-header-height: 40px;display:flex;align-items:center;position:fixed;top:0;left:0;right:0;background:#fff}.top-nav-container[data-v-21d9b8e4]{align-items:center;width:100%}.top-title-name[data-v-21d9b8e4]{text-align:center;position:absolute;left:50%;transform:translate(-50%)}.main[data-v-21d9b8e4]{padding:0;margin:40px 0 0} '
);
var __getOwnPropNames = Object.getOwnPropertyNames;
var __commonJS = (cb, mod) =>
function __require() {
return (mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports);
};
var require_entrance_001 = __commonJS({
"entrance-C5IXQq4N.js"(exports, module) {
var _GM_deleteValue = (() => (typeof GM_deleteValue != "undefined" ? GM_deleteValue : void 0))();
var _GM_getResourceText = (() => (typeof GM_getResourceText != "undefined" ? GM_getResourceText : void 0))();
var _GM_getValue = (() => (typeof GM_getValue != "undefined" ? GM_getValue : void 0))();
var _GM_info = (() => (typeof GM_info != "undefined" ? GM_info : void 0))();
var _GM_listValues = (() => (typeof GM_listValues != "undefined" ? GM_listValues : void 0))();
var _GM_registerMenuCommand = (() =>
typeof GM_registerMenuCommand != "undefined" ? GM_registerMenuCommand : void 0)();
var _GM_setValue = (() => (typeof GM_setValue != "undefined" ? GM_setValue : void 0))();
var _GM_setValues = (() => (typeof GM_setValues != "undefined" ? GM_setValues : void 0))();
var _GM_unregisterMenuCommand = (() =>
typeof GM_unregisterMenuCommand != "undefined" ? GM_unregisterMenuCommand : void 0)();
var _GM_xmlhttpRequest = (() => (typeof GM_xmlhttpRequest != "undefined" ? GM_xmlhttpRequest : void 0))();
var _unsafeWindow = (() => (typeof unsafeWindow != "undefined" ? unsafeWindow : void 0))();
var _monkeyWindow = (() => window)();
const BaiduRouter = {
isSearch() {
return Boolean(window.location.href.match(/^http(s|):\/\/(m[0-9]{0,2}|www).baidu.com\/.*/g));
},
isSearchBh() {
return Boolean(this.isSearch() && window.location.pathname.startsWith("/bh"));
},
isSearchVideo() {
return Boolean(this.isSearch() && window.location.pathname.startsWith("/video/page"));
},
isSearchHome() {
return Boolean(
window.location.href.match(/^http(s|):\/\/(m[0-9]{0,2}|www).baidu.com\/$/g) ||
window.location.href.match(/^http(s|):\/\/(m[0-9]{0,2}|www).baidu.com\/(\?ref=|\?tn=|\?from=|#\/)/g)
);
},
isSearchVSearch() {
return this.isSearch() && window.location.pathname.startsWith("/sf/vsearch");
},
isSearchVSearch_image_content() {
let searchParams = new URLSearchParams(window.location.search);
return this.isSearchVSearch() && searchParams.has("pd", "image_content");
},
isSearchVSearch_note() {
let searchParams = new URLSearchParams(window.location.search);
return this.isSearchVSearch() && searchParams.has("pd", "note");
},
isSearchWenDaTab() {
let searchParams = new URLSearchParams(window.location.search);
return this.isSearchVSearch() && searchParams.has("pd", "wenda_tab");
},
isBaiJiaHao() {
return Boolean(window.location.href.match(/^http(s|):\/\/baijiahao.baidu.com/g));
},
isTieBa() {
return Boolean(
window.location.href.match(
/^http(s|):\/\/(tieba|ala|static.tieba|nba|fexclick|youhua|tiebaswan).baidu.com/g
) || window.location.href.match(/^http(s|):\/\/(www.tieba|jump2.bdimg).com/g)
);
},
isTieBaPost() {
return Boolean(this.isTieBa() && window.location.pathname.startsWith("/p/"));
},
isTieBaNewTopic() {
return Boolean(this.isTieBa() && window.location.pathname.startsWith("/mo/q/newtopic/topicTemplate"));
},
isTieBaHottopic() {
return Boolean(this.isTieBa() && window.location.pathname.startsWith("/hottopic/browse/hottopic"));
},
isTieBaHybrid() {
return Boolean(this.isTieBa() && window.location.pathname.startsWith("/mo/q/hybrid/search"));
},
isTieBaHybridUserGrowBase() {
return Boolean(
this.isTieBa() && window.location.pathname.startsWith("/mo/q/hybrid-usergrow-base/commentFocus")
);
},
isTieBaCheckUrl() {
return Boolean(this.isTieBa() && window.location.pathname.startsWith("/mo/q/checkurl"));
},
isTieBaNei() {
return Boolean(this.isTieBa() && window.location.pathname === "/f");
},
isTieBaIndex() {
return Boolean(this.isTieBa() && window.location.pathname.startsWith("/index"));
},
isTieBaHome() {
return Boolean(this.isTieBa() && window.location.pathname.startsWith("/home/main"));
},
isTieBaCollectionCenter() {
return Boolean(
this.isTieBa() && window.location.pathname.startsWith("/mo/q/hybrid-main-user/collectionCenter")
);
},
isWenKu() {
return Boolean(window.location.href.match(/^http(s|):\/\/(wk|tanbi).baidu.com/g));
},
isJingYan() {
return Boolean(window.location.href.match(/^http(s|):\/\/jingyan.baidu.com/g));
},
isBaiKe() {
return Boolean(window.location.href.match(/^http(s|):\/\/(baike|wapbaike).baidu.com/g));
},
isBaiKeTaShuo() {
return Boolean(this.isBaiKe() && window.location.pathname.startsWith("/tashuo"));
},
isZhiDao() {
return Boolean(window.location.href.match(/^http(s|):\/\/zhidao.baidu.com/g));
},
isFanYi() {
return Boolean(window.location.href.match(/^http(s|):\/\/fanyi.baidu.com/g));
},
isFanYiApp() {
return Boolean(window.location.href.match(/^http(s|):\/\/fanyi-app.baidu.com/g));
},
isImage() {
return Boolean(window.location.href.match(/^http(s|):\/\/image.baidu.com/g));
},
isMap() {
return Boolean(window.location.href.match(/^http(s|):\/\/map.baidu.com/g));
},
isMbd() {
return Boolean(window.location.href.match(/^http(s|):\/\/mbd.baidu.com/g));
},
isXue() {
return Boolean(window.location.href.match(/^http(s|):\/\/xue.baidu.com/g));
},
isAiQiCha() {
return Boolean(window.location.href.match(/^http(s|):\/\/aiqicha.baidu.com/g));
},
isPos() {
return Boolean(window.location.href.match(/^http(s|):\/\/pos.baidu.com/g));
},
isHaoKan() {
return Boolean(window.location.href.match(/^http(s|):\/\/haokan.baidu.com/g));
},
isGraph() {
return Boolean(window.location.href.match(/^http(s|):\/\/graph.baidu.com/g));
},
isPan() {
return Boolean(window.location.href.match(/^http(s|):\/\/pan.baidu.com/g));
},
isYiYan() {
return Boolean(window.location.href.match(/^http(s|):\/\/yiyan.baidu.com/g));
},
isChat() {
return Boolean(window.location.href.match(/^http(s|):\/\/chat.baidu.com/g));
},
isMiniJiaoYu() {
return Boolean(window.location.href.match(/^http(s|):\/\/uf9kyh.smartapps.cn/g));
},
isEasyLearn() {
return Boolean(window.location.href.match(/^http(s|):\/\/easylearn.baidu.com/g));
},
isISite() {
return Boolean(window.location.href.match(/^http(s|):\/\/isite.baidu.com\/site\/wjz2tdly/g));
},
isAiStudy() {
return Boolean(window.location.href.match(/^http(s|):\/\/aistudy.baidu.com/g));
},
isSmartApps_Tieba() {
return Boolean(window.location.hostname === "byokpg.smartapps.baidu.com");
},
};
const KEY = "GM_Panel";
const ATTRIBUTE_INIT = "data-init";
const ATTRIBUTE_KEY = "data-key";
const ATTRIBUTE_DEFAULT_VALUE = "data-default-value";
const ATTRIBUTE_INIT_MORE_VALUE = "data-init-more-value";
const ATTRIBUTE_PLUGIN_SEARCH_CONFIG = "data-plugin-search-config";
const PROPS_STORAGE_API = "data-storage-api";
const PanelSizeUtil = {
get width() {
return globalThis.innerWidth;
},
get height() {
return globalThis.innerHeight;
},
};
const PanelUISize = {
setting: {
get width() {
if (PanelSizeUtil.width < 550) {
return "88vw";
} else if (PanelSizeUtil.width < 700) {
return "550px";
} else {
return "700px";
}
},
get height() {
if (PanelSizeUtil.height < 450) {
return "70vh";
} else if (PanelSizeUtil.height < 550) {
return "450px";
} else {
return "550px";
}
},
},
settingMiddle: {
get width() {
return PanelSizeUtil.width < 350 ? "88vw" : "350px";
},
},
info: {
get width() {
return PanelSizeUtil.width < 350 ? "88vw" : "350px";
},
get height() {
return PanelSizeUtil.height < 250 ? "88vh" : "250px";
},
},
};
class StorageUtils {
storageKey;
listenerData;
constructor(key) {
if (typeof key === "string") {
const trimKey = key.trim();
if (trimKey == "") {
throw new Error("key参数不能为空字符串");
}
this.storageKey = trimKey;
} else {
throw new Error("key参数类型错误,必须是字符串");
}
this.listenerData = new Utils.Dictionary();
this.getLocalValue = this.getLocalValue.bind(this);
this.set = this.set.bind(this);
this.get = this.get.bind(this);
this.getAll = this.getAll.bind(this);
this.delete = this.delete.bind(this);
this.has = this.has.bind(this);
this.keys = this.keys.bind(this);
this.values = this.values.bind(this);
this.clear = this.clear.bind(this);
this.addValueChangeListener = this.addValueChangeListener.bind(this);
this.removeValueChangeListener = this.removeValueChangeListener.bind(this);
this.triggerValueChangeListener = this.triggerValueChangeListener.bind(this);
}
getLocalValue() {
let localValue = _GM_getValue(this.storageKey);
if (localValue == null) {
localValue = {};
this.setLocalValue(localValue);
}
return localValue;
}
setLocalValue(value) {
_GM_setValue(this.storageKey, value);
}
set(key, value) {
const oldValue = this.get(key);
const localValue = this.getLocalValue();
Reflect.set(localValue, key, value);
this.setLocalValue(localValue);
this.triggerValueChangeListener(key, oldValue, value);
}
get(key, defaultValue) {
const localValue = this.getLocalValue();
return Reflect.get(localValue, key) ?? defaultValue;
}
getAll() {
const localValue = this.getLocalValue();
return localValue;
}
delete(key) {
const oldValue = this.get(key);
const localValue = this.getLocalValue();
Reflect.deleteProperty(localValue, key);
this.setLocalValue(localValue);
this.triggerValueChangeListener(key, oldValue, void 0);
}
has(key) {
const localValue = this.getLocalValue();
return Reflect.has(localValue, key);
}
keys() {
const localValue = this.getLocalValue();
return Reflect.ownKeys(localValue);
}
values() {
const localValue = this.getLocalValue();
return Reflect.ownKeys(localValue).map((key) => Reflect.get(localValue, key));
}
clear() {
_GM_deleteValue(this.storageKey);
}
addValueChangeListener(key, callback) {
const listenerId = Math.random();
const listenerData = this.listenerData.get(key) || [];
listenerData.push({
id: listenerId,
key,
callback,
});
this.listenerData.set(key, listenerData);
return listenerId;
}
removeValueChangeListener(listenerId) {
let flag = false;
for (const [key, listenerData] of this.listenerData.entries()) {
for (let index = 0; index < listenerData.length; index++) {
const value = listenerData[index];
if (
(typeof listenerId === "string" && value.key === listenerId) ||
(typeof listenerId === "number" && value.id === listenerId)
) {
listenerData.splice(index, 1);
index--;
flag = true;
}
}
this.listenerData.set(key, listenerData);
}
return flag;
}
async triggerValueChangeListener(...args) {
const [key, oldValue, newValue] = args;
if (!this.listenerData.has(key)) {
return;
}
let listenerData = this.listenerData.get(key);
for (let index = 0; index < listenerData.length; index++) {
const data = listenerData[index];
if (typeof data.callback === "function") {
let value = this.get(key);
let __newValue;
let __oldValue;
if (typeof oldValue !== "undefined" && args.length >= 2) {
__oldValue = oldValue;
} else {
__oldValue = value;
}
if (typeof newValue !== "undefined" && args.length > 2) {
__newValue = newValue;
} else {
__newValue = value;
}
await data.callback(key, __oldValue, __newValue);
}
}
}
}
const PopsPanelStorageApi = new StorageUtils(KEY);
const CommonUtil = {
waitRemove(...args) {
args.forEach((selector) => {
if (typeof selector !== "string") {
return;
}
DOMUtils.waitNodeList(selector).then((nodeList) => {
nodeList.forEach(($el) => $el.remove());
});
});
},
createBlockCSSNode(...args) {
let selectorList = [];
if (args.length === 0) {
return;
}
if (args.length === 1 && typeof args[0] === "string" && args[0].trim() === "") {
return;
}
args.forEach((selector) => {
if (Array.isArray(selector)) {
selectorList = selectorList.concat(selector);
} else {
selectorList.push(selector);
}
});
return DOMUtils.createElement("style", {
type: "text/css",
innerHTML: `${selectorList.join(",\n")}{display: none !important;}`,
});
},
addBlockCSS(...args) {
let selectorList = [];
if (args.length === 0) {
return;
}
if (args.length === 1 && typeof args[0] === "string" && args[0].trim() === "") {
return;
}
args.forEach((selector) => {
if (Array.isArray(selector)) {
selectorList = selectorList.concat(selector);
} else {
selectorList.push(selector);
}
});
return addStyle$1(`${selectorList.join(",\n")}{display: none !important;}`);
},
setGMResourceCSS(resourceMapData) {
const cssText =
typeof _GM_getResourceText === "function" ? _GM_getResourceText(resourceMapData.keyName) : null;
if (typeof cssText === "string" && cssText) {
return addStyle$1(cssText);
} else {
return CommonUtil.loadStyleLink(resourceMapData.url);
}
},
async loadStyleLink(url) {
let $link = document.createElement("link");
$link.rel = "stylesheet";
$link.type = "text/css";
$link.href = url;
return new Promise((resolve) => {
DOMUtils.ready(() => {
document.head.appendChild($link);
resolve($link);
});
});
},
async loadScript(url) {
let $script = document.createElement("script");
$script.src = url;
return new Promise((resolve) => {
$script.onload = () => {
resolve(null);
};
(document.head || document.documentElement).appendChild($script);
});
},
fixUrl(url) {
url = url.trim();
if (url.startsWith("data:")) {
return url;
}
if (url.match(/^http(s|):\/\//i)) {
return url;
} else if (url.startsWith("//")) {
if (url.startsWith("///"));
else {
url = window.location.protocol + url;
}
return url;
} else {
if (!url.startsWith("/")) {
url += "/";
}
url = window.location.origin + url;
return url;
}
},
fixHttps(url) {
if (url.startsWith("https://")) {
return url;
}
if (!url.startsWith("http://")) {
return url;
}
try {
let urlInstance = new URL(url);
urlInstance.protocol = "https:";
return urlInstance.toString();
} catch {
return url;
}
},
lockScroll(...args) {
let $hidden = document.createElement("style");
$hidden.innerHTML = `
.pops-overflow-hidden-important {
overflow: hidden !important;
}
`;
let $elList = [document.documentElement, document.body].concat(...(args || []));
$elList.forEach(($el) => {
$el.classList.add("pops-overflow-hidden-important");
});
(document.head || document.documentElement).appendChild($hidden);
return {
recovery() {
$elList.forEach(($el) => {
$el.classList.remove("pops-overflow-hidden-important");
});
$hidden.remove();
},
};
},
async getClipboardText() {
function readClipboardText(resolve) {
navigator.clipboard
.readText()
.then((clipboardText) => {
resolve(clipboardText);
})
.catch((error) => {
log.error("读取剪贴板内容失败👉", error);
resolve("");
});
}
function requestPermissionsWithClipboard(resolve) {
navigator.permissions
.query({
name: "clipboard-read",
})
.then((permissionStatus) => {
readClipboardText(resolve);
})
.catch((error) => {
log.error("申请剪贴板权限失败,尝试直接读取👉", error.message ?? error.name ?? error.stack);
readClipboardText(resolve);
});
}
function checkClipboardApi() {
if (typeof navigator?.clipboard?.readText !== "function") {
return false;
}
if (typeof navigator?.permissions?.query !== "function") {
return false;
}
return true;
}
return new Promise((resolve) => {
if (!checkClipboardApi()) {
resolve("");
return;
}
if (document.hasFocus()) {
requestPermissionsWithClipboard(resolve);
} else {
window.addEventListener(
"focus",
() => {
requestPermissionsWithClipboard(resolve);
},
{
once: true,
}
);
}
});
},
escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(//g, ">")
.replace(/"/g, """)
.replace(/'/g, "'")
.replace(/©/g, "©")
.replace(/®/g, "®")
.replace(/™/g, "™")
.replace(/→/g, "→")
.replace(/←/g, "←")
.replace(/↑/g, "↑")
.replace(/↓/g, "↓")
.replace(/—/g, "—")
.replace(/–/g, "–")
.replace(/…/g, "…")
.replace(/ /g, " ")
.replace(/\r\n/g, "
")
.replace(/\r/g, "
")
.replace(/\n/g, "
")
.replace(/\t/g, " ");
},
interval(fn, intervalTime, timeout = 5e3) {
let timeId;
let maxTimeout = timeout - intervalTime;
let intervalTimeCount = intervalTime;
let loop = async (isTimeout) => {
let result = await fn(isTimeout);
if ((typeof result === "boolean" && !result) || isTimeout) {
utils.workerClearTimeout(timeId);
return;
}
intervalTimeCount += intervalTime;
if (intervalTimeCount > maxTimeout) {
loop(true);
return;
}
timeId = utils.workerSetTimeout(() => {
loop(false);
}, intervalTime);
};
loop(false);
},
findParentNode($el, selector, parentSelector) {
if (parentSelector) {
let $parent = DOMUtils.closest($el, parentSelector);
if ($parent) {
let $target = $parent.querySelector(selector);
return $target;
}
} else {
if (DOMUtils.matches($el, selector)) {
return $el;
}
let $parent = DOMUtils.closest($el, selector);
return $parent;
}
},
toStr(data) {
const undefinedReplacedStr = `__undefined__placeholder__replaced__str__`;
const dataStr = JSON.stringify(
data,
(key, value) => {
return value === void 0 ? undefinedReplacedStr : value;
},
2
).replace(new RegExp(`"${undefinedReplacedStr}"`, "g"), "undefined");
return dataStr;
},
};
const PanelContent = {
$data: {
__contentConfig: null,
get contentConfig() {
if (this.__contentConfig == null) {
this.__contentConfig = new utils.Dictionary();
}
return this.__contentConfig;
},
__defaultBottomContentConfig: [],
},
addContentConfig(configList) {
if (!Array.isArray(configList)) {
configList = [configList];
}
let index = this.$data.contentConfig.keys().length;
this.$data.contentConfig.set(index, configList);
},
getAllContentConfig() {
return this.$data.contentConfig.values().flat();
},
getConfig(index = 0) {
return this.$data.contentConfig.get(index) ?? [];
},
getDefaultBottomContentConfig() {
if (this.$data.__defaultBottomContentConfig.length) {
return this.$data.__defaultBottomContentConfig;
}
let isDoubleClick = false;
let timer = void 0;
const exportToFile = (fileName, fileData) => {
if (typeof fileData !== "string") {
fileData = CommonUtil.toStr(fileData);
}
const blob = new Blob([fileData]);
const blobUrl = globalThis.URL.createObjectURL(blob);
const $anchor = domUtils.createElement("a", {
href: blobUrl,
download: fileName,
});
$anchor.click();
utils.workerSetTimeout(() => {
globalThis.URL.revokeObjectURL(blobUrl);
}, 500);
};
const dbclick_callback = () => {
const importConfig = (importEndCallBack) => {
const $alert = __pops__.alert({
title: {
text: "请选择导入方式",
position: "center",
},
content: {
text: `
本地导入
网络导入
剪贴板导入
`,
html: true,
},
btn: {
ok: { enable: false },
close: {
enable: true,
callback(details, event) {
details.close();
},
},
},
drag: true,
mask: {
enable: true,
},
width: PanelUISize.info.width,
height: PanelUISize.info.height,
style: `
.btn-control{
display: inline-block;
margin: 10px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
cursor: pointer;
}
.btn-control:hover{
color: #409eff;
border-color: #c6e2ff;
background-color: #ecf5ff;
}`,
});
const $local = $alert.$shadowRoot.querySelector(".btn-control[data-mode='local']");
const $network = $alert.$shadowRoot.querySelector(".btn-control[data-mode='network']");
const $clipboard = $alert.$shadowRoot.querySelector(".btn-control[data-mode='clipboard']");
const updateConfigToStorage = async (data) => {
const clearLocalStorage = confirm("是否清空脚本存储的配置?(如果点击取消按钮,则仅做配置覆盖处理)");
if (clearLocalStorage) {
if (typeof _GM_listValues === "function") {
if (typeof _GM_deleteValue === "function") {
const localStorageKeys = _GM_listValues();
localStorageKeys.forEach((key) => {
_GM_deleteValue(key);
});
Qmsg.success("已清空脚本存储的配置");
} else {
Qmsg.error("不支持GM_deleteValue函数,无法执行删除脚本配置");
}
} else {
Qmsg.error("不支持GM_listValues函数,无法清空脚本存储的配置");
}
}
if (typeof _GM_setValues === "function") {
_GM_setValues(data);
} else {
const keys = Object.keys(data);
keys.forEach((key) => {
const value = data[key];
_GM_setValue(key, value);
});
}
Qmsg.success("配置导入完毕");
};
const importFile = (configText) => {
return new Promise(async (resolve) => {
const data = utils.toJSON(configText);
if (Object.keys(data).length === 0) {
Qmsg.warning("解析为空配置,不导入");
} else {
await updateConfigToStorage(data);
}
resolve(true);
});
};
domUtils.on($local, "click", (event) => {
domUtils.preventEvent(event);
$alert.close();
const $input = domUtils.createElement("input", {
type: "file",
accept: ".json",
});
domUtils.on($input, ["propertychange", "input"], (event2) => {
if (!$input.files?.length) {
return;
}
const uploadFile = $input.files[0];
const fileReader = new FileReader();
fileReader.onload = () => {
importFile(fileReader.result);
};
fileReader.readAsText(uploadFile, "UTF-8");
});
$input.click();
});
domUtils.on($network, "click", (event) => {
domUtils.preventEvent(event);
$alert.close();
const $prompt = __pops__.prompt({
title: {
text: "网络导入",
position: "center",
},
content: {
text: "",
placeholder: "请填写URL",
focus: true,
},
btn: {
close: {
enable: true,
callback(details, event2) {
details.close();
},
},
ok: {
text: "导入",
callback: async (details, event2) => {
const url = details.text;
if (utils.isNull(url)) {
Qmsg.error("请填入完整的url");
return;
}
const $loading = Qmsg.loading("正在获取配置...");
const response = await httpx.get(url, {
allowInterceptConfig: false,
});
$loading.close();
if (!response.status) {
log.error(response);
Qmsg.error("获取配置失败", { consoleLogContent: true });
return;
}
const flag = await importFile(response.data.responseText);
if (!flag) {
return;
}
details.close();
},
},
cancel: {
enable: false,
},
},
drag: true,
mask: {
enable: true,
},
width: PanelUISize.info.width,
height: "auto",
});
const $promptInput = $prompt.$shadowRoot.querySelector("input");
const $promptOk = $prompt.$shadowRoot.querySelector(".pops-prompt-btn-ok");
domUtils.on($promptInput, ["input", "propertychange"], (event2) => {
const value = domUtils.val($promptInput);
if (value === "") {
domUtils.attr($promptOk, "disabled", "true");
} else {
domUtils.removeAttr($promptOk, "disabled");
}
});
domUtils.listenKeyboard($promptInput, "keydown", (keyName, keyValue, otherCodeList) => {
if (keyName === "Enter" && otherCodeList.length === 0) {
const value = domUtils.val($promptInput);
if (value !== "") {
domUtils.trigger($promptOk, "click");
}
}
});
domUtils.trigger($promptInput, "input");
});
domUtils.on($clipboard, "click", async (event) => {
domUtils.preventEvent(event);
$alert.close();
let clipboardText = await CommonUtil.getClipboardText();
if (clipboardText.trim() === "") {
Qmsg.warning("获取到的剪贴板内容为空");
return;
}
const flag = await importFile(clipboardText);
if (!flag) {
return;
}
});
};
const exportConfig = (
fileName = `${SCRIPT_NAME}_panel-setting-${utils.formatTime(Date.now(), "yyyy_MM_dd_HH_mm_ss")}.json`,
fileData
) => {
const $alert = __pops__.alert({
title: {
text: "请选择导出方式",
position: "center",
},
content: {
text: `
导出至文件
导出至剪贴板
`,
html: true,
},
btn: {
ok: { enable: false },
close: {
enable: true,
callback(details, event) {
details.close();
},
},
},
drag: true,
mask: {
enable: true,
},
width: PanelUISize.info.width,
height: PanelUISize.info.height,
style: `
.btn-control{
display: inline-block;
margin: 10px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
cursor: pointer;
}
.btn-control:hover{
color: #409eff;
border-color: #c6e2ff;
background-color: #ecf5ff;
}`,
});
const $exportToFile = $alert.$shadowRoot.querySelector(".btn-control[data-mode='export-to-file']");
const $exportToClipboard = $alert.$shadowRoot.querySelector(
".btn-control[data-mode='export-to-clipboard']"
);
domUtils.on($exportToFile, "click", (event) => {
domUtils.preventEvent(event);
try {
exportToFile(fileName, fileData);
$alert.close();
} catch (error) {
Qmsg.error(error.toString(), { consoleLogContent: true });
}
});
domUtils.on($exportToClipboard, "click", async (event) => {
const result = await utils.copy(fileData);
if (result) {
Qmsg.success("复制成功");
$alert.close();
} else {
Qmsg.error("复制失败");
}
});
};
const $dialog = __pops__.confirm({
title: {
text: "配置",
position: "center",
},
content: {
text: `
`,
html: true,
},
btn: {
ok: {
enable: true,
type: "primary",
text: "导入",
callback(eventDetails, event) {
importConfig();
},
},
cancel: {
enable: true,
text: "导出",
callback(eventDetails, event) {
exportConfig(void 0, configDataStr);
},
},
},
width: PanelSizeUtil.width < 450 ? "90vw" : "450px",
height: "auto",
style: `
.pops-content textarea {
--textarea-bd-color: #dcdfe6;
display: inline-block;
resize: vertical;
padding: 5px 15px;
margin: 0;
line-height: normal;
box-sizing: border-box;
color: #606266;
border: 0;
border-radius: 0;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background: none;
width: 100%;
height: 100%;
appearance: none;
resize: none;
}
.pops-content textarea{
height: 500px;
}
.pops-content textarea:focus {
--textarea-bd-color: #3677f0;
}
.pops-content textarea:hover {
--textarea-bd-color: #c0c4cc;
}
`,
});
const $textarea = $dialog.$shadowRoot.querySelector("textarea");
const configData = {};
if (typeof _GM_listValues === "function") {
const LocalKeys = _GM_listValues();
LocalKeys.forEach((key) => {
const value = _GM_getValue(key);
Reflect.set(configData, key, value);
});
} else {
Qmsg.warning("不支持函数GM_listValues,仅导出菜单配置");
const panelLocalValue = _GM_getValue(KEY);
Reflect.set(configData, KEY, panelLocalValue);
}
const configDataStr = CommonUtil.toStr(configData);
$textarea.value = configDataStr;
};
const click_callback = () => {
let supportURL = _GM_info?.script?.supportURL || _GM_info?.script?.namespace;
if (typeof supportURL === "string" && utils.isNotNull(supportURL)) {
window.open(supportURL, "_blank");
}
};
return [
{
id: "script-version",
title: `版本:${_GM_info?.script?.version || "未知"}`,
isBottom: true,
forms: [],
clickFirstCallback() {
return false;
},
afterRender(config) {
const anyTouch = new AnyTouch(config.$asideLiElement);
anyTouch.on("tap", function (event) {
clearTimeout(timer);
timer = void 0;
if (isDoubleClick) {
isDoubleClick = false;
dbclick_callback();
} else {
timer = setTimeout(() => {
isDoubleClick = false;
click_callback();
}, 200);
isDoubleClick = true;
}
});
},
},
];
},
setDefaultBottomContentConfig(config) {
this.$data.__defaultBottomContentConfig = config;
},
};
const PanelMenu = {
$data: {
__menuOption: [
{
key: "show_pops_panel_setting",
text: "⚙ 设置",
autoReload: false,
isStoreValue: false,
showText(text) {
return text;
},
callback: () => {
Panel.showPanel(PanelContent.getConfig(0));
},
},
],
get menuOption() {
return this.__menuOption;
},
},
init() {
this.initExtensionsMenu();
},
initExtensionsMenu() {
if (!Panel.isTopWindow()) {
return;
}
GM_Menu.add(this.$data.menuOption);
},
addMenuOption(option) {
if (!Array.isArray(option)) {
option = [option];
}
this.$data.menuOption.push(...option);
},
updateMenuOption(option) {
if (!Array.isArray(option)) {
option = [option];
}
option.forEach((optionItem) => {
let findIndex = this.$data.menuOption.findIndex((it) => {
return it.key === optionItem.key;
});
if (findIndex !== -1) {
this.$data.menuOption[findIndex] = optionItem;
}
});
},
getMenuOption(index = 0) {
return this.$data.menuOption[index];
},
deleteMenuOption(index = 0) {
this.$data.menuOption.splice(index, 1);
},
};
const Panel = {
$data: {
__contentConfigInitDefaultValue: null,
__onceExecMenuData: null,
__urlChangeReloadMenuExecOnce: null,
__onceExecData: null,
__panelConfig: {},
$panel: null,
panelContent: [],
get contentConfigInitDefaultValue() {
if (this.__contentConfigInitDefaultValue == null) {
this.__contentConfigInitDefaultValue = new utils.Dictionary();
}
return this.__contentConfigInitDefaultValue;
},
contentConfigInitDisabledKeys: [],
get onceExecMenuData() {
if (this.__onceExecMenuData == null) {
this.__onceExecMenuData = new utils.Dictionary();
}
return this.__onceExecMenuData;
},
get urlChangeReloadMenuExecOnce() {
if (this.__urlChangeReloadMenuExecOnce == null) {
this.__urlChangeReloadMenuExecOnce = new utils.Dictionary();
}
return this.__urlChangeReloadMenuExecOnce;
},
get onceExecData() {
if (this.__onceExecData == null) {
this.__onceExecData = new utils.Dictionary();
}
return this.__onceExecData;
},
get scriptName() {
return SCRIPT_NAME;
},
get panelConfig() {
return this.__panelConfig;
},
set panelConfig(value) {
this.__panelConfig = value;
},
key: KEY,
attributeKeyName: ATTRIBUTE_KEY,
attributeDefaultValueName: ATTRIBUTE_DEFAULT_VALUE,
},
init() {
this.initContentDefaultValue();
PanelMenu.init();
},
isTopWindow() {
return _unsafeWindow.top === _unsafeWindow.self;
},
initContentDefaultValue() {
const initDefaultValue = (config) => {
if (!config.attributes) {
return;
}
if (config.type === "button" || config.type === "forms" || config.type === "deepMenu") {
return;
}
const attributes = config.attributes;
let __attr_init__ = attributes[ATTRIBUTE_INIT];
if (typeof __attr_init__ === "function") {
let __attr_result__ = __attr_init__();
if (typeof __attr_result__ === "boolean" && !__attr_result__) {
return;
}
}
let menuDefaultConfig = new Map();
let key = attributes[ATTRIBUTE_KEY];
if (key != null) {
const defaultValue = attributes[ATTRIBUTE_DEFAULT_VALUE];
menuDefaultConfig.set(key, defaultValue);
}
let moreMenuDefaultConfig = attributes[ATTRIBUTE_INIT_MORE_VALUE];
if (typeof moreMenuDefaultConfig === "object" && moreMenuDefaultConfig) {
Object.keys(moreMenuDefaultConfig).forEach((key2) => {
const defaultValue = moreMenuDefaultConfig[key2];
menuDefaultConfig.set(key2, defaultValue);
});
}
if (!menuDefaultConfig.size) {
log.warn(["请先配置键", config]);
return;
}
if (config.type === "switch") {
let disabled = typeof config.disabled === "function" ? config.disabled() : config.disabled;
if (typeof disabled === "boolean" && disabled) {
this.$data.contentConfigInitDisabledKeys.push(...menuDefaultConfig.keys());
}
}
for (const [__key, __defaultValue] of menuDefaultConfig.entries()) {
this.setDefaultValue(__key, __defaultValue);
}
};
const loopInitDefaultValue = (configList) => {
for (let index = 0; index < configList.length; index++) {
let configItem = configList[index];
initDefaultValue(configItem);
let child_forms = configItem.forms;
if (child_forms && Array.isArray(child_forms)) {
loopInitDefaultValue(child_forms);
}
}
};
const contentConfigList = [...PanelContent.getAllContentConfig()];
for (let index = 0; index < contentConfigList.length; index++) {
let leftContentConfigItem = contentConfigList[index];
if (!leftContentConfigItem.forms) {
continue;
}
const rightContentConfigList = leftContentConfigItem.forms;
if (rightContentConfigList && Array.isArray(rightContentConfigList)) {
loopInitDefaultValue(rightContentConfigList);
}
}
this.$data.contentConfigInitDisabledKeys = [...new Set(this.$data.contentConfigInitDisabledKeys)];
},
setDefaultValue(key, defaultValue) {
if (this.$data.contentConfigInitDefaultValue.has(key)) {
log.warn("请检查该key(已存在): " + key);
}
this.$data.contentConfigInitDefaultValue.set(key, defaultValue);
},
getDefaultValue(key) {
return this.$data.contentConfigInitDefaultValue.get(key);
},
setValue(key, value) {
PopsPanelStorageApi.set(key, value);
},
getValue(key, defaultValue) {
const localValue = PopsPanelStorageApi.get(key);
if (localValue == null) {
if (this.$data.contentConfigInitDefaultValue.has(key)) {
return this.$data.contentConfigInitDefaultValue.get(key);
}
return defaultValue;
}
return localValue;
},
deleteValue(key) {
PopsPanelStorageApi.delete(key);
},
hasKey(key) {
return PopsPanelStorageApi.has(key);
},
addValueChangeListener(key, callback) {
const listenerId = PopsPanelStorageApi.addValueChangeListener(key, (__key, __newValue, __oldValue) => {
callback(key, __oldValue, __newValue);
});
return listenerId;
},
removeValueChangeListener(listenerId) {
PopsPanelStorageApi.removeValueChangeListener(listenerId);
},
triggerMenuValueChange(key, newValue, oldValue) {
PopsPanelStorageApi.triggerValueChangeListener(key, oldValue, newValue);
},
async exec(queryKey, callback, checkExec, once = true) {
const that = this;
let queryKeyFn;
if (typeof queryKey === "string" || Array.isArray(queryKey)) {
queryKeyFn = () => queryKey;
} else {
queryKeyFn = queryKey;
}
let isArrayKey = false;
const queryKeyResult = queryKeyFn();
let keyList = [];
if (Array.isArray(queryKeyResult)) {
isArrayKey = true;
keyList = queryKeyResult;
} else {
keyList.push(queryKeyResult);
}
const findNotInDataKey = keyList.find((it) => !this.$data.contentConfigInitDefaultValue.has(it));
if (findNotInDataKey) {
log.warn(`${findNotInDataKey} 键不存在`);
return;
}
const storageKey = JSON.stringify(keyList);
if (once) {
if (this.$data.onceExecMenuData.has(storageKey)) {
return this.$data.onceExecMenuData.get(storageKey);
}
}
let storeValueList = [];
const listenerIdList = [];
let destoryFnList = [];
const addStoreValueCallback = (enableValue, args) => {
let dynamicMenuStoreValueList = [];
let dynamicDestoryFnList = [];
let resultValueList = [];
if (Array.isArray(args)) {
resultValueList = resultValueList.concat(args);
} else {
if (typeof args === "object" && args != null) {
if (args instanceof Element) {
resultValueList.push(args);
} else {
const { $css, destory } = args;
if ($css != null) {
if (Array.isArray($css)) {
resultValueList = resultValueList.concat($css);
} else {
resultValueList.push($css);
}
}
if (typeof destory === "function") {
resultValueList.push(destory);
}
}
} else {
resultValueList.push(args);
}
}
for (const it of resultValueList) {
if (it == null) {
continue;
}
if (it instanceof Element) {
dynamicMenuStoreValueList.push(it);
continue;
}
if (typeof it === "function") {
destoryFnList.push(it);
continue;
}
}
if (enableValue) {
storeValueList = storeValueList.concat(dynamicMenuStoreValueList);
destoryFnList = destoryFnList.concat(dynamicDestoryFnList);
} else {
execClearStoreStyleElements();
execDestory();
}
};
const getMenuValue = (key) => {
const value = this.getValue(key);
return Boolean(value);
};
const execClearStoreStyleElements = () => {
for (let index = 0; index < storeValueList.length; index++) {
const $css = storeValueList[index];
$css?.remove();
storeValueList.splice(index, 1);
index--;
}
};
const execDestory = () => {
for (let index = 0; index < destoryFnList.length; index++) {
const destoryFnItem = destoryFnList[index];
destoryFnItem();
destoryFnList.splice(index, 1);
index--;
}
};
const checkMenuExec = () => {
let flag = false;
if (typeof checkExec === "function") {
flag = checkExec(keyList);
} else {
flag = keyList.every((key) => getMenuValue(key));
}
return flag;
};
const valueChangeCallback = async (valueOption) => {
const execFlag = checkMenuExec();
if (execFlag) {
const valueList = keyList.map((key) => this.getValue(key));
const callbackResult = await callback({
value: isArrayKey ? valueList : valueList[0],
addStoreValue: (...args) => {
return addStoreValueCallback(true, args);
},
});
addStoreValueCallback(true, callbackResult);
} else {
addStoreValueCallback(false, []);
}
};
once &&
keyList.forEach((key) => {
const listenerId = this.addValueChangeListener(key, (key2, newValue, oldValue) => {
return valueChangeCallback();
});
listenerIdList.push(listenerId);
});
await valueChangeCallback();
const result = {
reload() {
this.clearStoreStyleElements();
this.destory();
valueChangeCallback();
},
clear() {
this.clearStoreStyleElements();
this.destory();
this.removeValueChangeListener();
this.clearOnceExecMenuData();
},
clearStoreStyleElements: () => {
return execClearStoreStyleElements();
},
destory() {
return execDestory();
},
removeValueChangeListener: () => {
listenerIdList.forEach((listenerId) => {
this.removeValueChangeListener(listenerId);
});
},
clearOnceExecMenuData() {
once && that.$data.onceExecMenuData.delete(storageKey);
},
};
this.$data.onceExecMenuData.set(storageKey, result);
return result;
},
async execMenu(key, callback, isReverse = false, once = false) {
return await this.exec(
key,
async (option) => {
return await callback(option);
},
(keyList) => {
const execFlag = keyList.every((__key__) => {
let flag = !!this.getValue(__key__);
const disabled = Panel.$data.contentConfigInitDisabledKeys.includes(__key__);
if (disabled) {
flag = false;
log.warn(`.execMenu${once ? "Once" : ""} ${__key__} 被禁用`);
}
isReverse && (flag = !flag);
return flag;
});
return execFlag;
},
once
);
},
async execMenuOnce(key, callback, isReverse = false, listenUrlChange = false) {
const result = await this.execMenu(key, callback, isReverse, true);
if (listenUrlChange) {
if (result) {
const urlChangeEvent = () => {
result.reload();
};
this.removeUrlChangeWithExecMenuOnceListener(key);
this.addUrlChangeWithExecMenuOnceListener(key, urlChangeEvent);
}
}
return result;
},
deleteExecMenuOnce(key) {
key = this.transformKey(key);
this.$data.onceExecMenuData.delete(key);
this.$data.urlChangeReloadMenuExecOnce.delete(key);
const flag = PopsPanelStorageApi.removeValueChangeListener(key);
return flag;
},
onceExec(key, callback) {
key = this.transformKey(key);
if (typeof key !== "string") {
throw new TypeError("key 必须是字符串");
}
if (this.$data.onceExecData.has(key)) {
return;
}
callback();
this.$data.onceExecData.set(key, 1);
},
deleteOnceExec(key) {
key = this.transformKey(key);
this.$data.onceExecData.delete(key);
},
addUrlChangeWithExecMenuOnceListener(key, callback) {
key = this.transformKey(key);
this.$data.urlChangeReloadMenuExecOnce.set(key, callback);
},
removeUrlChangeWithExecMenuOnceListener(key) {
key = this.transformKey(key);
this.$data.urlChangeReloadMenuExecOnce.delete(key);
},
hasUrlChangeWithExecMenuOnceListener(key) {
key = this.transformKey(key);
return this.$data.urlChangeReloadMenuExecOnce.has(key);
},
async triggerUrlChangeWithExecMenuOnceEvent(config) {
const values = this.$data.urlChangeReloadMenuExecOnce.values();
for (const callback of values) {
await callback(config);
}
},
showPanel(
content,
title = `${SCRIPT_NAME}-设置`,
preventDefaultContentConfig = false,
preventRegisterSearchPlugin = false
) {
this.$data.$panel = null;
this.$data.panelContent = [];
let checkHasBottomVersionContentConfig =
content.findIndex((it) => {
let isBottom = typeof it.isBottom === "function" ? it.isBottom() : Boolean(it.isBottom);
return isBottom && it.id === "script-version";
}) !== -1;
if (!preventDefaultContentConfig && !checkHasBottomVersionContentConfig) {
content.push(...PanelContent.getDefaultBottomContentConfig());
}
let $panel = __pops__.panel({
...{
title: {
text: title,
position: "center",
html: false,
style: "",
},
content,
btn: {
close: {
enable: true,
callback: (details, event) => {
details.close();
this.$data.$panel = null;
},
},
},
mask: {
enable: true,
clickEvent: {
toClose: true,
toHide: false,
},
clickCallBack: (originalRun, config) => {
originalRun();
this.$data.$panel = null;
},
},
width: PanelUISize.setting.width,
height: PanelUISize.setting.height,
drag: true,
only: true,
},
...this.$data.panelConfig,
});
this.$data.$panel = $panel;
this.$data.panelContent = content;
if (!preventRegisterSearchPlugin) {
this.registerConfigSearch({ $panel, content });
}
},
registerConfigSearch(config) {
const { $panel, content } = config;
const asyncQueryProperty = async (target, handler) => {
if (target == null) {
return;
}
const handleResult = await handler(target);
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
return handleResult.data;
}
return await asyncQueryProperty(handleResult.data, handler);
};
const scrollToElementAndListen = ($el, callback) => {
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
callback?.();
observer.disconnect();
}
});
},
{
root: null,
threshold: 1,
}
);
observer.observe($el);
$el.scrollIntoView({ behavior: "smooth", block: "center" });
};
const addFlashingClass = ($el) => {
const flashingClassName = "pops-flashing";
domUtils.animationend($el, () => {
$el.classList.remove(flashingClassName);
});
$el.classList.add(flashingClassName);
};
const dbclick_callback = (evt) => {
if (evt.type === "dblclick" && isMobileTouch) {
return;
}
domUtils.preventEvent(evt);
clickElement = null;
const $alert = __pops__.alert({
title: {
text: "搜索配置",
position: "center",
},
content: {
text: `
`,
html: true,
},
btn: {
ok: { enable: false },
},
mask: {
clickEvent: {
toClose: true,
},
},
width: PanelUISize.settingMiddle.width,
height: "auto",
drag: true,
style: `
${__pops__.config.cssText.panelCSS}
.search-wrapper{
border-bottom: 1px solid rgb(235, 238, 245, 1);
}
.pops-content:has(.search-result-wrapper:empty) .search-wrapper{
border-bottom: 0;
}
.search-config-text{
width: 100%;
border: 0;
height: 32px;
padding: 0px 10px;
outline: none;
}
.search-result-wrapper{
max-height: 400px;
overflow: auto;
}
.search-result-item{
cursor: pointer;
padding: 5px 10px;
display: flex;
flex-direction: column;
}
.search-result-item:hover{
background-color: #D8F1FD;
}
.search-result-item-path{
display: flex;
align-items: center;
}
.search-result-item-description{
font-size: 0.8em;
color: #6c6c6c;
}
${config.searchDialogStyle ?? ""}
`,
});
$alert.$shadowRoot.querySelector(".search-wrapper");
const $searchInput = $alert.$shadowRoot.querySelector(".search-config-text");
const $searchResultWrapper = $alert.$shadowRoot.querySelector(".search-result-wrapper");
$searchInput.focus();
const clearSearchResult = () => {
domUtils.empty($searchResultWrapper);
};
const createSearchResultItem = (pathInfo) => {
const searchPath = utils.queryProperty(pathInfo, (target) => {
if (target?.next) {
return {
isFind: false,
data: target.next,
};
} else {
return {
isFind: true,
data: target,
};
}
});
const $item = domUtils.createElement("div", {
className: "search-result-item",
innerHTML: `
${searchPath.matchedData?.path}
${searchPath.matchedData?.description ?? ""}
`,
});
domUtils.on($item, "click", (clickItemEvent) => {
const $asideItems2 = $panel.$shadowRoot.querySelectorAll(
"aside.pops-panel-aside .pops-panel-aside-top-container li"
);
const $targetAsideItem = $asideItems2[pathInfo.index];
if (!$targetAsideItem) {
Qmsg.error(`左侧项下标${pathInfo.index}不存在`);
return;
}
$targetAsideItem.scrollIntoView({
behavior: "smooth",
block: "center",
});
$targetAsideItem.click();
asyncQueryProperty(pathInfo.next, async (target) => {
if (target?.next) {
const $findDeepMenu = await domUtils.waitNode(() => {
return Array.from($panel.$shadowRoot.querySelectorAll(".pops-panel-deepMenu-nav-item")).find(
($deepMenu) => {
const __formConfig__ = Reflect.get($deepMenu, "__formConfig__");
return (
typeof __formConfig__ === "object" &&
__formConfig__ != null &&
__formConfig__.text === target.name
);
}
);
}, 2500);
if ($findDeepMenu) {
$findDeepMenu.click();
} else {
Qmsg.error("未找到对应的二级菜单");
return {
isFind: true,
data: target,
};
}
return {
isFind: false,
data: target.next,
};
} else {
const $findTargetMenu = await domUtils.waitNode(() => {
return Array.from(
$panel.$shadowRoot.querySelectorAll(`li:not(.pops-panel-deepMenu-nav-item)`)
).find(($menuItem) => {
const __formConfig__ = Reflect.get($menuItem, "__formConfig__");
return __formConfig__ === target.matchedData?.formConfig;
});
}, 2500);
if ($findTargetMenu) {
scrollToElementAndListen($findTargetMenu);
const $fold = $findTargetMenu.closest(`.pops-panel-forms-fold[data-fold-enable]`);
if ($fold) {
const $foldWrapper = $fold.querySelector(".pops-panel-forms-fold-container");
$foldWrapper.click();
await utils.sleep(500);
}
scrollToElementAndListen($findTargetMenu, () => {
addFlashingClass($findTargetMenu);
});
} else {
Qmsg.error("未找到对应的菜单项");
}
return {
isFind: true,
data: target,
};
}
});
});
return $item;
};
const execSearch = (searchText) => {
const searchTextRegExp = new RegExp(searchText, "i");
const searchConfigResult = [];
const loopContentConfig = (configList, path) => {
for (let index = 0; index < configList.length; index++) {
const configItem = configList[index];
const child_forms = configItem.forms;
if (child_forms && Array.isArray(child_forms)) {
const deepMenuPath = utils.deepClone(path);
if (configItem.type === "deepMenu") {
const deepNext = utils.queryProperty(deepMenuPath, (target) => {
if (target?.next) {
return {
isFind: false,
data: target.next,
};
} else {
return {
isFind: true,
data: target,
};
}
});
deepNext.next = {
name: configItem.text,
};
}
loopContentConfig(child_forms, deepMenuPath);
} else {
let text;
let description;
if (configItem.type === "own") {
const searchConfig = Reflect.get(configItem.attributes || {}, ATTRIBUTE_PLUGIN_SEARCH_CONFIG);
if (searchConfig) {
if (typeof searchConfig.text === "string") {
text = searchConfig.text;
}
if (typeof searchConfig.desc === "string") {
description = searchConfig.desc;
}
}
} else {
text = Reflect.get(configItem, "text");
description = Reflect.get(configItem, "description");
}
const delayMatchedTextList = [text, description];
const matchedIndex = delayMatchedTextList.findIndex((configText) => {
if (typeof configText !== "string") {
return;
}
return configText.match(searchTextRegExp);
});
if (matchedIndex !== -1) {
const matchedPath = utils.deepClone(path);
const deepNext = utils.queryProperty(matchedPath, (target) => {
if (target?.next) {
return {
isFind: false,
data: target.next,
};
} else {
return {
isFind: true,
data: target,
};
}
});
deepNext.next = {
name: text,
matchedData: {
path: "",
formConfig: configItem,
matchedText: delayMatchedTextList[matchedIndex],
description,
},
};
const pathList = [];
utils.queryProperty(matchedPath, (target) => {
const name = target?.name;
if (typeof name === "string" && name.trim() !== "") {
pathList.push(name);
}
if (target?.next) {
return {
isFind: false,
data: target.next,
};
} else {
return {
isFind: true,
data: target,
};
}
});
const pathStr = pathList.join(CommonUtil.escapeHtml(" - "));
deepNext.next.matchedData.path = pathStr;
searchConfigResult.push(matchedPath);
}
}
}
};
for (let index = 0; index < content.length; index++) {
const leftContentConfigItem = content[index];
if (!leftContentConfigItem.forms) {
continue;
}
if (leftContentConfigItem.isBottom && leftContentConfigItem.id === "script-version") {
continue;
}
const rightContentConfigList = leftContentConfigItem.forms;
if (rightContentConfigList && Array.isArray(rightContentConfigList)) {
let text = leftContentConfigItem.title;
if (typeof text === "function") {
text = text();
}
loopContentConfig(rightContentConfigList, {
index,
name: text,
});
}
}
const fragment = document.createDocumentFragment();
for (const pathInfo of searchConfigResult) {
let $resultItem = createSearchResultItem(pathInfo);
fragment.appendChild($resultItem);
}
clearSearchResult();
$searchResultWrapper.append(fragment);
};
domUtils.on(
$searchInput,
"input",
utils.debounce((evt2) => {
domUtils.preventEvent(evt2);
let searchText = domUtils.val($searchInput).trim();
if (searchText === "") {
clearSearchResult();
return;
}
execSearch(searchText);
}, 200)
);
};
const $asideItems = $panel.$shadowRoot.querySelectorAll(
`aside.pops-panel-aside .pops-panel-aside-item:not(#script-version)`
);
$asideItems.forEach(($asideItem) => {
domUtils.on($asideItem, "dblclick", dbclick_callback);
});
let clickElement = null;
let isDoubleClick = false;
let timer = void 0;
let isMobileTouch = false;
domUtils.on(
$panel.$shadowRoot,
"touchend",
`aside.pops-panel-aside .pops-panel-aside-item:not(#script-version)`,
(evt, selectorTarget) => {
isMobileTouch = true;
clearTimeout(timer);
timer = void 0;
if (isDoubleClick && clickElement === selectorTarget) {
isDoubleClick = false;
clickElement = null;
dbclick_callback(evt);
} else {
timer = setTimeout(() => {
isDoubleClick = false;
}, 200);
isDoubleClick = true;
clickElement = selectorTarget;
}
},
{
capture: true,
}
);
$panel.$shadowRoot.appendChild(
domUtils.createElement("style", {
type: "text/css",
textContent: `
.pops-flashing{
animation: double-blink 1.5s ease-in-out;
}
@keyframes double-blink {
0% {
background-color: initial;
}
25% {
background-color: yellow;
}
50% {
background-color: initial;
}
75% {
background-color: yellow;
}
100% {
background-color: initial;
}
}
`,
})
);
},
transformKey(key) {
if (Array.isArray(key)) {
const keyArray = key.sort();
return JSON.stringify(keyArray);
} else {
return key;
}
},
};
const GM_RESOURCE_MAPPING = {
ElementPlus: {
keyName: "ElementPlusResourceCSS",
url: "https://fastly.jsdelivr.net/npm/element-plus@latest/dist/index.min.css",
},
Viewer: {
keyName: "ViewerCSS",
url: "https://fastly.jsdelivr.net/npm/viewerjs@latest/dist/viewer.min.css",
},
};
const PanelSettingConfig = {
qmsg_config_position: {
key: "qmsg-config-position",
defaultValue: "bottom",
},
qmsg_config_maxnums: {
key: "qmsg-config-maxnums",
defaultValue: 3,
},
qmsg_config_showreverse: {
key: "qmsg-config-showreverse",
defaultValue: false,
},
};
const utils = Utils.noConflict();
const domUtils = DOMUtils.noConflict();
const __pops__ = pops;
const log = new utils.Log(_GM_info, _unsafeWindow.console || _monkeyWindow.console);
const SCRIPT_NAME = _GM_info?.script?.name || void 0;
const AnyTouch = pops.config.Utils.AnyTouch();
const DEBUG = false;
log.config({
debug: false,
logMaxCount: 250,
autoClearConsole: true,
tag: true,
});
Qmsg.config({
isHTML: true,
autoClose: true,
showClose: false,
consoleLogContent(qmsgInst) {
const qmsgType = qmsgInst.getSetting().type;
if (qmsgType === "loading") {
return false;
}
const content = qmsgInst.getSetting().content;
if (qmsgType === "warning") {
log.warn(content);
} else if (qmsgType === "error") {
log.error(content);
} else {
log.info(content);
}
return true;
},
get position() {
return Panel.getValue(
PanelSettingConfig.qmsg_config_position.key,
PanelSettingConfig.qmsg_config_position.defaultValue
);
},
get maxNums() {
return Panel.getValue(
PanelSettingConfig.qmsg_config_maxnums.key,
PanelSettingConfig.qmsg_config_maxnums.defaultValue
);
},
get showReverse() {
return Panel.getValue(
PanelSettingConfig.qmsg_config_showreverse.key,
PanelSettingConfig.qmsg_config_showreverse.defaultValue
);
},
get zIndex() {
let maxZIndex = Utils.getMaxZIndex();
let popsMaxZIndex = pops.config.InstanceUtils.getPopsMaxZIndex().zIndex;
return Utils.getMaxValue(maxZIndex, popsMaxZIndex) + 100;
},
});
__pops__.GlobalConfig.setGlobalConfig({
zIndex: () => {
const maxZIndex = Utils.getMaxZIndex(void 0, void 0, ($ele) => {
if ($ele?.classList?.contains("qmsg-shadow-container")) {
return false;
}
if ($ele?.closest("qmsg") && $ele.getRootNode() instanceof ShadowRoot) {
return false;
}
});
const popsMaxZIndex = pops.config.InstanceUtils.getPopsMaxZIndex().zIndex;
return Utils.getMaxValue(maxZIndex, popsMaxZIndex) + 100;
},
mask: {
enable: true,
clickEvent: {
toClose: false,
toHide: false,
},
},
drag: true,
});
const GM_Menu = new utils.GM_Menu({
GM_getValue: _GM_getValue,
GM_setValue: _GM_setValue,
GM_registerMenuCommand: _GM_registerMenuCommand,
GM_unregisterMenuCommand: _GM_unregisterMenuCommand,
});
const httpx = new utils.Httpx({
xmlHttpRequest: _GM_xmlhttpRequest,
logDetails: DEBUG,
});
httpx.interceptors.request.use((data) => {
return data;
});
httpx.interceptors.response.use(void 0, (data) => {
log.error("拦截器-请求错误", data);
if (data.type === "onabort") {
Qmsg.warning("请求取消", { consoleLogContent: true });
} else if (data.type === "onerror") {
Qmsg.error("请求异常", { consoleLogContent: true });
} else if (data.type === "ontimeout") {
Qmsg.error("请求超时", { consoleLogContent: true });
} else {
Qmsg.error("其它错误", { consoleLogContent: true });
}
return data;
});
const OriginPrototype = {
Object: {
defineProperty: _unsafeWindow.Object.defineProperty,
},
Function: {
apply: _unsafeWindow.Function.prototype.apply,
call: _unsafeWindow.Function.prototype.call,
},
Element: {
appendChild: _unsafeWindow.Element.prototype.appendChild,
},
setTimeout: _unsafeWindow.setTimeout,
};
const addStyle$1 = domUtils.addStyle.bind(domUtils);
const $ = DOMUtils.selector.bind(DOMUtils);
const $$ = DOMUtils.selectorAll.bind(DOMUtils);
const VUE_ROOT_ID = "vite-app";
const MountVue = async function (rootComponent, plugins = []) {
CommonUtil.setGMResourceCSS(GM_RESOURCE_MAPPING.ElementPlus);
await DOMUtils.ready();
const app = vue.createApp(rootComponent);
const $mount = DOMUtils.createElement("div", {
id: VUE_ROOT_ID,
});
{
if (ElementPlusIconsVue != null) {
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component);
}
}
}
document.body.appendChild($mount);
plugins.forEach((item) => {
app.use(item);
});
const mountResult = app.mount($mount);
return mountResult;
};
new utils.GM_Cookie();
class LoadingView {
config;
loadingViewElement;
loadingViewHTML;
loadingViewIconHTML;
constructor(withIcon, isEnd) {
this.config = {
className: "whitesev-load-view",
textClassName: "whitesev-load-view-text",
iconClassName: "whitesev-load-view-icon",
outSideClassName: "whitesev-load-view-icon-outside",
withInClassName: "whitesev-load-view-icon-within",
};
this.loadingViewElement = void 0;
this.loadingViewHTML = `
Loading...
`.trim();
this.loadingViewIconHTML = `
`.trim();
this.initCSS();
this.initLoadingView(withIcon, isEnd);
}
initCSS() {
if (this.isExistsCSS()) {
return;
}
let loadingViewCSSText = `
.${this.config.className}{
margin: 0.08rem;
background: #fff;
font-size: 15px;
text-align: center;
width: inherit;
border-radius: 0.12rem;
}
.${this.config.iconClassName}{
width: 45px;
}
.${this.config.className},
.${this.config.iconClassName}{
height: 45px;
line-height: 45px;
display: flex;
align-items: center;
justify-content: center;
}
.${this.config.outSideClassName},
.${this.config.withInClassName}{
position: absolute;
margin-left: 140px;
border: 5px solid rgba(0, 183, 229, 0.9);
opacity: .9;
border-radius: 50px;
width: 20px;
height: 20px;
margin: 0 auto;
}
.${this.config.outSideClassName}{
background-color: rgba(0, 0, 0, 0);
border-right: 5px solid rgba(0, 0, 0, 0);
border-left: 5px solid rgba(0, 0, 0, 0);
box-shadow: 0 0 35px #2187e7;
-moz-animation: spinPulse 1s infinite ease-in-out;
-webkit-animation: spinPulse 1s infinite ease-in-out;
-o-animation: spinPulse 1s infinite ease-in-out;
-ms-animation: spinPulse 1s infinite ease-in-out;
}
.${this.config.withInClassName}{
background: rgba(0, 0, 0, 0) no-repeat center center;
border-top: 5px solid rgba(0, 0, 0, 0);
border-bottom: 5px solid rgba(0, 0, 0, 0);
box-shadow: 0 0 15px #2187e7;
-moz-animation: spinoffPulse 3s infinite linear;
-webkit-animation: spinoffPulse 3s infinite linear;
-o-animation: spinoffPulse 3s infinite linear;
-ms-animation: spinoffPulse 3s infinite linear;
}
@-moz-keyframes spinPulse{0%{-moz-transform:rotate(160deg);opacity:0;box-shadow:0 0 1px #505050}
50%{-moz-transform:rotate(145deg);opacity:1}
100%{-moz-transform:rotate(-320deg);opacity:0}
}
@-moz-keyframes spinoffPulse{0%{-moz-transform:rotate(0)}
100%{-moz-transform:rotate(360deg)}
}
@-webkit-keyframes spinPulse{0%{-webkit-transform:rotate(160deg);opacity:0;box-shadow:0 0 1px #505050}
50%{-webkit-transform:rotate(145deg);opacity:1}
100%{-webkit-transform:rotate(-320deg);opacity:0}
}
@-webkit-keyframes spinoffPulse{0%{-webkit-transform:rotate(0)}
100%{-webkit-transform:rotate(360deg)}
}
@-o-keyframes spinPulse{0%{-o-transform:rotate(160deg);opacity:0;box-shadow:0 0 1px #505050}
50%{-o-transform:rotate(145deg);opacity:1}
100%{-o-transform:rotate(-320deg);opacity:0}
}
@-o-keyframes spinoffPulse{0%{-o-transform:rotate(0)}
100%{-o-transform:rotate(360deg)}
}
@-ms-keyframes spinPulse{0%{-ms-transform:rotate(160deg);opacity:0;box-shadow:0 0 1px #505050}
50%{-ms-transform:rotate(145deg);opacity:1}
100%{-ms-transform:rotate(-320deg);opacity:0}
}
@-ms-keyframes spinoffPulse{0%{-ms-transform:rotate(0)}
100%{-ms-transform:rotate(360deg)}
}
`;
domUtils.addStyle(loadingViewCSSText);
}
initLoadingView(withIcon = false, isEnd = true) {
this.setLoadingViewElement();
let divElement = document.createElement("div");
divElement.innerHTML = this.loadingViewHTML;
let resultElement = divElement.firstChild;
if (withIcon) {
let iconElement = document.createElement("div");
iconElement.innerHTML = this.loadingViewIconHTML;
if (isEnd) {
resultElement.appendChild(iconElement.firstChild);
} else {
resultElement.insertBefore(iconElement.firstChild, resultElement.firstChild);
}
}
this.setLoadingViewElement(resultElement);
return resultElement;
}
setLoadingViewElement(element) {
this.loadingViewElement = element;
}
getLoadingViewElement() {
if (!this.loadingViewElement) {
throw new Error("object loadingViewElement is null");
}
return this.loadingViewElement;
}
getIconElement() {
return this.getLoadingViewElement().querySelector("." + this.config.iconClassName);
}
show() {
this.getLoadingViewElement().style.display = "";
}
hide() {
this.getLoadingViewElement().style.display = "none";
}
showIcon() {
let iconElement = this.getIconElement();
iconElement && (iconElement.style.display = "");
}
hideIcon() {
let iconElement = this.getIconElement();
iconElement && (iconElement.style.display = "none");
}
setText(text, withIcon = false, isEnd = true) {
this.getLoadingViewElement().innerHTML = `${text}`;
if (withIcon) {
let iconElement = this.getIconElement();
if (!iconElement) {
let divElement = document.createElement("div");
divElement.innerHTML = this.loadingViewIconHTML;
iconElement = divElement.firstChild;
if (isEnd) {
this.getLoadingViewElement().appendChild(iconElement);
} else {
this.getLoadingViewElement().insertBefore(iconElement, this.getLoadingViewElement().firstChild);
}
}
iconElement.style.display = "";
} else {
this.getIconElement()?.remove();
}
}
setHTML(text) {
this.getLoadingViewElement().innerHTML = text;
}
destory() {
this.getLoadingViewElement()?.remove();
this.setLoadingViewElement();
}
removeAll() {
document.querySelectorAll("." + this.config.className).forEach((item) => item.remove());
}
isExists() {
return Boolean(document.querySelector(`.${this.config.className}`));
}
isExistsIcon() {
return Boolean(this.getIconElement());
}
isExistsText() {
return Boolean(this.getLoadingViewElement().querySelector(`.${this.config.textClassName}`));
}
isExistsCSS() {
return Boolean(
document.querySelector("style[data-from='loadingView'][type='text/css'][data-author='whitesev']")
);
}
}
_monkeyWindow.showdown || _unsafeWindow.showdown;
const loadingView = new LoadingView(true);
const SearchShieldCSS = `.c-container.na-ec-item,\r
.c-container.ec-container,\r
div[data-type="ad"],\r
.c-result.sfc-log[data-tpl="adv_wenku_fc"],\r
.c-recomm-wrap.new-ux-recom-wrapper.animation,\r
#results-pre,\r
.video-recommend,\r
.c-result.sfc-log[data-tpl="search_recomm"],\r
.sfc-image-content-waterfall-item[wat-item-data-id="no-img"],\r
.se-results-pre,\r
.ec_wise_ad,\r
div#copyright + div,\r
div#pop-up,\r
div[class*='ad-wrapper__'],\r
div[class*='rec-wrapper__'],\r
.brand-entry,\r
.barea-ad,\r
.swan-ad-fc-rcmd.swan-ad-fc-base-wrap[data-platform],\r
div#page-bd div.recommend,\r
div.short-mini div[data-module="rec:undefined-undefined"],\r
/* 相关软件 */\r
div[srcid="sigma_celebrity_rela"],\r
/* 搜一些隐私的内容时弹出的来的,开启无痕模式----保护隐私,安全浏览 */\r
div:has(p.ivk-private-p),\r
/* 智能卡片的 更多 按钮 */\r
.c-result-content div[rl-type="stop"]:has(div[data-module="lgsd"]) {\r
display: none !important;\r
}\r
/* 搜索框 */\r
.searchboxtop.newsearch-white-style .se-form {\r
border-color: #4e6ef2 !important;\r
}\r
/* 百度一下 按钮 */\r
.searchboxtop.newsearch-white-style .se-bn {\r
color: #fff !important;\r
background: #4e6ef2 !important;\r
}\r
.se-head-logo .se-logo img {\r
display: inherit !important;\r
}\r
/* 选项卡,如综合、笔记、视频等 */\r
.se-head-tablink {\r
border-bottom: 1px solid #e6e6e6 !important;\r
/*background-color: #fff !important;*/\r
background-color: transparent !important;\r
}\r
\r
a.se-tabitem span {\r
color: #000 !important;\r
}\r
/*div.c-peak-layer{\r
display:none !important;\r
} 百度关键字背景*/\r
.se-tablink-scroll-wrapper .se-tab-cur:after {\r
border-bottom: 2px solid #38f !important;\r
}\r
.c-tags-scroll.c-padding-x {\r
display: none !important;\r
}\r
.white-bdsearch-isredirecrt {\r
display: inline-flex;\r
background: #43ba76;\r
color: #fff;\r
width: 28px;\r
font-size: 16px;\r
line-height: 25px;\r
justify-content: center;\r
align-items: center;\r
border-radius: 5px;\r
margin: 0 auto;\r
margin-right: 6px;\r
}\r
/* 修复图片显示问题 */\r
.image-strong-card div[class*="image-content__"] > div {\r
display: inline-block;\r
overflow: hidden;\r
vertical-align: top;\r
}\r
.c-result-content div[class*="tieba-newxml-forum-img-class__"] {\r
display: -webkit-box;\r
display: -webkit-flex;\r
display: flex;\r
-webkit-box-align: center;\r
-moz-box-align: center;\r
-webkit-align-items: center;\r
align-items: center;\r
}\r
\r
.c-result-content div[class*="tieba-newxml-forum-img__"] {\r
width: 0.553rem;\r
height: 0.553rem;\r
}\r
\r
.c-result-content div[class*="tieba-newxml-forum-img__"] img {\r
width: 100%;\r
height: 100%;\r
border-radius: 0.09rem;\r
}\r
.c-result-content div[class*="tieba-newxml-forum-class__"] {\r
display: -webkit-flex;\r
display: flex;\r
-webkit-box-orient: vertical;\r
-moz-box-orient: vertical;\r
-webkit-box-direction: normal;\r
-moz-box-direction: normal;\r
-webkit-flex-direction: column;\r
-moz-flex-direction: column;\r
flex-direction: column;\r
-webkit-box-pack: center;\r
-moz-box-pack: center;\r
-webkit-justify-content: center;\r
-moz-justify-content: center;\r
justify-content: center;\r
max-width: 2.2rem;\r
}\r
.c-result-content div[class*="c-img-content-btn__"] {\r
position: absolute;\r
right: 0;\r
width: 0.55rem;\r
text-align: center;\r
line-height: 0.28rem;\r
border: 1px solid rgba(31, 31, 31, 0.5);\r
border-radius: 0.15rem;\r
font-family: PingFangSC-Medium;\r
font-size: 0.13rem;\r
color: #1f1f1f;\r
}\r
.c-result-content div[class*="tieba-newxml-thread-comment-user__"] {\r
display: -webkit-flex;\r
display: flex;\r
-webkit-box-align: center;\r
-moz-box-align: center;\r
-webkit-align-items: center;\r
-moz-align-items: center;\r
align-items: center;\r
margin-top: 0.03rem;\r
}\r
.c-result-content div[class*="tieba-newxml-thread-comment-user__"] img {\r
width: 0.16rem;\r
height: 0.16rem;\r
border-radius: 50%;\r
}\r
.c-result-content div[class*="tieba-newxml-thread-comment-user__"] span {\r
margin-right: 0.08rem;\r
}\r
.whitesev-gm-refactor-everyone-searching {\r
width: 100%;\r
box-sizing: border-box;\r
height: 2.857em;\r
line-height: 2.857;\r
background-color: #f5f6f9;\r
border-color: #f5f6f9;\r
padding: 0 0.08rem;\r
/*vertical-align: middle;*/\r
outline: 0;\r
font-size: 14px;\r
overflow: hidden;\r
border-radius: 9px;\r
text-align: center;\r
text-decoration: none;\r
-webkit-tap-highlight-color: transparent;\r
-moz-tap-highlight-color: transparent;\r
text-overflow: ellipsis;\r
white-space: nowrap;\r
-webkit-box-orient: horizontal;\r
-moz-box-orient: horizontal;\r
-webkit-box-align: stretch;\r
-moz-box-align: stretch;\r
display: block;\r
justify-content: space-between;\r
-webkit-justify-content: space-between;\r
-moz-justify-content: space-between;\r
-webkit-align-items: stretch;\r
-moz-align-items: stretch;\r
align-items: stretch;\r
flex-wrap: nowrap;\r
-webkit-flex-wrap: nowrap;\r
-moz-flex-wrap: nowrap;\r
}\r
\r
/* 让搜索中某些视频的阶段可以横向滚动 */\r
div[class^="new-summary-container_"] {\r
overflow: auto;\r
}\r
\r
/* 智能卡片 展开更多,这里是拼音 */\r
.c-result-content div[class*="multi-pinyin_"] div[class*="multi-pinyin-item"][style*="display: none"] {\r
display: block !important;\r
}\r
`;
const SearchHealthShieldCSS =
'/* 右下角悬浮的健康直播间图标按钮 */\r\ndiv[class^="index_brandEntry"],\r\n/* 底部的推荐的广告 */\r\n.moduleItemWrap:has([data-ad-id]) {\r\n display: none !important;\r\n}\r\n';
const BaiduHeadlth = {
init() {
addStyle$1(SearchHealthShieldCSS);
log.info("插入CSS规则");
Panel.execMenuOnce("baidu_search_headlth_shield_other_info", () => {
return this.shieldOtherInfo();
});
Panel.execMenuOnce("baidu_search_headlth_shield_bottom_toolbar", () => {
return this.shieldServiceButtonsRow();
});
},
shieldOtherInfo() {
log.info("【屏蔽】底部其它信息");
return CommonUtil.addBlockCSS(
'article[class] > div[class^="index_container"]',
'#main > div[class^="index_container"]'
);
},
shieldServiceButtonsRow() {
log.info("【屏蔽】底部工具栏");
return CommonUtil.addBlockCSS(
'article[class] > div[class^="index_healthServiceButtonsRow"]',
'#main > div[class^="index_interactWrap"]'
);
},
};
const BaiduHook = {
$isHook: {
windowBoxJSBefore: false,
objectDefineProperty_search: false,
windowJQueryAppend: false,
windowOpenBox: false,
windowWebpackJsonp_tieba: false,
windowWebpackJsonp_haokan: false,
window_openContentBox: false,
functionCall_baijiahao_map: false,
},
$data: {
functionApply: [],
functionCall: [],
elementAppendChild: [],
setTimeout: [],
windowDefine: [],
},
functionApply(mode) {
this.$data.functionApply.push(mode);
if (this.$data.functionApply.length > 1) {
log.info("Function.property.apply hook新增劫持参数:" + mode);
return;
}
let that = this;
log.info("初始化Function.property.apply hook");
_unsafeWindow.Function.prototype.apply = function (...args) {
if (that.$data.functionApply.includes("copy")) {
try {
let firstParam = args[1];
if (
args.length === 2 &&
typeof firstParam === "object" &&
"" + firstParam === "[object Arguments]" &&
firstParam.length === 1 &&
typeof firstParam[0] === "object" &&
firstParam[0] != null &&
"appName" in firstParam[0] &&
"checkTokenCopied" in firstParam[0] &&
"deeplink" in firstParam[0] &&
"scheme" in firstParam[0] &&
"token" in firstParam[0] &&
"useDeeplink" in firstParam[0]
) {
log.success(["劫持复制到剪贴板函数", ...firstParam]);
return new Promise(function (resolve) {
log.success(["修改参数并劫持复制到剪贴板返回true"]);
resolve({
status: true,
});
});
}
} catch (error) {}
}
if (that.$data.functionApply.includes("scheme")) {
try {
let firstParam = args[1];
if (
args.length === 2 &&
typeof firstParam === "object" &&
"" + firstParam === "[object Arguments]" &&
firstParam.length === 2 &&
firstParam[1] === "scheme"
) {
log.success(["劫持Scheme", ...firstParam]);
return;
}
} catch (error) {}
}
return OriginPrototype.Function.apply.call(this, ...args);
};
},
functionCall(mode) {
this.$data.functionCall.push(mode);
if (this.$data.functionCall.length > 1) {
log.info("Function.property.call hook新增劫持参数:" + mode);
return;
}
log.info("初始化Function.property.call hook");
let originCall = _unsafeWindow.Function.prototype.call;
_unsafeWindow.Function.prototype.call = function (...args) {
let result = originCall.apply(this, args);
if (mode === "baijiahao_invoke") {
if (
args.length === 4 &&
typeof args[1]?.["exports"] === "object" &&
"execCopy" in args[1]?.["exports"] &&
"invokeApp" in args[1]?.["exports"] &&
"invokeMarket" in args[1]?.["exports"] &&
"invokeTpApp" in args[1]?.["exports"]
) {
args[1]["exports"]["execCopy"] = function (...args2) {
return new Promise((resolve) => {
log.success(["阻止调用execCopy", args2]);
resolve(null);
});
};
args[1]["exports"]["invokeApp"] = function (...args2) {
return new Promise((resolve) => {
log.success(["阻止调用invokeApp", args2]);
resolve(null);
});
};
args[1]["exports"]["invokeMarket"] = function (...args2) {
return new Promise((resolve) => {
log.success(["阻止调用invokeMarket", args2]);
resolve(null);
});
};
args[1]["exports"]["invokeTpApp"] = function (...args2) {
return new Promise((resolve) => {
log.success(["阻止调用invokeTpApp", args2]);
resolve(null);
});
};
} else if (
args.length === 2 &&
args[0] === void 0 &&
args[1] != null &&
"arg" in args[1] &&
"delegate" in args[1] &&
"done" in args[1] &&
"method" in args[1] &&
"next" in args[1] &&
"prev" in args[1]
) {
log.success(["修改参数", args[1]]);
args[1]["method"] = "return";
args[1]["next"] = "end";
args[1]["prev"] = 24;
}
} else if (mode === "map") {
if (
args.length === 2 &&
args[0] === void 0 &&
args[1] != null &&
"arg" in args[1] &&
"delegate" in args[1] &&
"done" in args[1] &&
"method" in args[1] &&
"next" in args[1] &&
"prev" in args[1]
) {
log.success(["修改参数", args[1]]);
args[1]["method"] = "return";
args[1]["next"] = "end";
args[1]["prev"] = 24;
}
}
return result;
};
},
windowDefine(path, requirePathList, callback) {
this.$data.windowDefine.push({
path,
requirePathList,
callback,
});
if (this.$data.windowDefine.length > 1) {
log.info("define hook新增劫持参数:" + path);
return;
}
let that = this;
let safeDefine = void 0;
let unsafeDefine = function (...args) {
let define_path = args[0];
let define_requrePathList = args[1];
args[2];
for (let index = 0; index < that.$data.windowDefine.length; index++) {
let hookConfig = that.$data.windowDefine[index];
if (
hookConfig.path === define_path &&
JSON.stringify(hookConfig.requirePathList) === JSON.stringify(define_requrePathList)
) {
args[2] = hookConfig.callback;
break;
}
}
safeDefine(...args);
};
unsafeDefine.prototype.amd = {};
OriginPrototype.Object.defineProperty(_unsafeWindow, "define", {
get() {
if (safeDefine == null) {
return;
}
return unsafeDefine;
},
set(v) {
log.success(["define ==> ", v]);
safeDefine = v;
},
});
},
objectDefineProperty_search(menuKeyName) {
if (this.$isHook.objectDefineProperty_search) {
return;
}
this.$isHook.objectDefineProperty_search = true;
_unsafeWindow.Object.defineProperty = function (target, propertyKey, _attributes) {
if (propertyKey === "_onClick") {
log.info(["成功劫持_onClick", arguments]);
let oldFn = _attributes["value"];
_attributes["value"] = function (event) {
let eventNode = this._getNode(event.target);
let eventNodeName = this._getType(eventNode);
if (eventNodeName === "link") {
let linkProps2 = this._getLinkProps(eventNode);
log.success(["点击事件-linkProps信息", linkProps2]);
if (!linkProps2.href) {
domUtils.trigger(document, "click", event, false);
return;
}
domUtils.preventEvent(event);
if (Panel.getValue("baidu_search_hijack__onClick_to_blank")) {
log.success("新标签页打开: " + linkProps2.href);
window.open(linkProps2.href, "_blank");
} else {
window.location.href = linkProps2.href;
}
} else {
log.success(["点击事件-this._getType(eventNode)不为link", eventNodeName, event]);
oldFn.call(this, ...arguments);
}
};
}
return OriginPrototype.Object.defineProperty.call(this, ...arguments);
};
},
elementAppendChild(
handleCallBack = function (element) {
if (element instanceof HTMLIFrameElement) {
if (typeof element?.src === "string" && !element.src.startsWith("http")) {
log.success(["劫持iframe唤醒:" + element.src, element]);
return true;
}
}
}
) {
this.$data.elementAppendChild.push(handleCallBack);
if (this.$data.elementAppendChild.length > 1) {
log.info("Element.prototype.appendChild hook新增劫持判断回调");
return;
}
_unsafeWindow.Element.prototype.appendChild = function (element) {
if (typeof handleCallBack === "function") {
let handleResult = handleCallBack(element);
if (handleResult) {
return;
}
}
return OriginPrototype.Element.appendChild.call(this, ...arguments);
};
},
windowJQueryAppend() {
if (this.$isHook.windowJQueryAppend) {
return;
}
this.$isHook.windowJQueryAppend = true;
let originAppend = _unsafeWindow.$.fn.append;
_unsafeWindow.$.fn.append = function (params) {
if (typeof params === "string") {
params = params.trim();
if (params.startsWith('