// ==UserScript== // @name 网页高亮关键字 // @namespace http://tampermonkey.net/ // @version 0.99.7.06 // @description 对网页上的文字进行高亮显示,如果对你有帮助,可以随意修改使用 // @author You // @include * // @grant GM_addStyle // @grant GM_registerMenuCommand // @grant GM_setValue // @grant GM_getValue // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/465200/%E7%BD%91%E9%A1%B5%E9%AB%98%E4%BA%AE%E5%85%B3%E9%94%AE%E5%AD%97.user.js // @updateURL https://update.greasyfork.icu/scripts/465200/%E7%BD%91%E9%A1%B5%E9%AB%98%E4%BA%AE%E5%85%B3%E9%94%AE%E5%AD%97.meta.js // ==/UserScript== (function () { /*! * Vue.js v2.6.1 * (c) 2014-2019 Evan You * Released under the MIT License. */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Vue=t()}(this,function(){"use strict";var e=Object.freeze({});function t(e){return null==e}function n(e){return null!=e}function r(e){return!0===e}function i(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}function o(e){return null!==e&&"object"==typeof e}var a=Object.prototype.toString;function s(e){return"[object Object]"===a.call(e)}function c(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}function u(e){return n(e)&&"function"==typeof e.then&&"function"==typeof e.catch}function l(e){return null==e?"":Array.isArray(e)||s(e)&&e.toString===a?JSON.stringify(e,null,2):String(e)}function f(e){var t=parseFloat(e);return isNaN(t)?e:t}function p(e,t){for(var n=Object.create(null),r=e.split(","),i=0;i-1)return e.splice(n,1)}}var m=Object.prototype.hasOwnProperty;function y(e,t){return m.call(e,t)}function g(e){var t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}var _=/-(\w)/g,b=g(function(e){return e.replace(_,function(e,t){return t?t.toUpperCase():""})}),$=g(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}),w=/\B([A-Z])/g,C=g(function(e){return e.replace(w,"-$1").toLowerCase()});var x=Function.prototype.bind?function(e,t){return e.bind(t)}:function(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n};function A(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function k(e,t){for(var n in t)e[n]=t[n];return e}function O(e){for(var t={},n=0;n0,W=K&&K.indexOf("edge/")>0,Z=(K&&K.indexOf("android"),K&&/iphone|ipad|ipod|ios/.test(K)||"ios"===V),G=(K&&/chrome\/\d+/.test(K),K&&/phantomjs/.test(K),{}.watch),X=!1;if(U)try{var Y={};Object.defineProperty(Y,"passive",{get:function(){X=!0}}),window.addEventListener("test-passive",null,Y)}catch(e){}var Q=function(){return void 0===H&&(H=!U&&!z&&"undefined"!=typeof global&&(global.process&&"server"===global.process.env.VUE_ENV)),H},ee=U&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__;function te(e){return"function"==typeof e&&/native code/.test(e.toString())}var ne,re="undefined"!=typeof Symbol&&te(Symbol)&&"undefined"!=typeof Reflect&&te(Reflect.ownKeys);ne="undefined"!=typeof Set&&te(Set)?Set:function(){function e(){this.set=Object.create(null)}return e.prototype.has=function(e){return!0===this.set[e]},e.prototype.add=function(e){this.set[e]=!0},e.prototype.clear=function(){this.set=Object.create(null)},e}();var ie=S,oe=0,ae=function(){this.id=oe++,this.subs=[]};ae.prototype.addSub=function(e){this.subs.push(e)},ae.prototype.removeSub=function(e){h(this.subs,e)},ae.prototype.depend=function(){ae.target&&ae.target.addDep(this)},ae.prototype.notify=function(){for(var e=this.subs.slice(),t=0,n=e.length;t-1)if(o&&!y(i,"default"))a=!1;else if(""===a||a===C(e)){var c=De(String,i.type);(c<0||s0&&(at((u=e(u,(a||"")+"_"+c))[0])&&at(f)&&(s[l]=de(f.text+u[0].text),u.shift()),s.push.apply(s,u)):i(u)?at(f)?s[l]=de(f.text+u):""!==u&&s.push(de(u)):at(u)&&at(f)?s[l]=de(f.text+u.text):(r(o._isVList)&&n(u.tag)&&t(u.key)&&n(a)&&(u.key="__vlist"+a+"_"+c+"__"),s.push(u)));return s}(e):void 0}function at(e){return n(e)&&n(e.text)&&!1===e.isComment}function st(e,t){return(e.__esModule||re&&"Module"===e[Symbol.toStringTag])&&(e=e.default),o(e)?t.extend(e):e}function ct(e){return e.isComment&&e.asyncFactory}function ut(e){if(Array.isArray(e))for(var t=0;tdocument.createEvent("Event").timeStamp&&(Tt=function(){return performance.now()});var Nt=0,jt=function(e,t,n,r,i){this.vm=e,i&&(e._watcher=this),e._watchers.push(this),r?(this.deep=!!r.deep,this.user=!!r.user,this.lazy=!!r.lazy,this.sync=!!r.sync,this.before=r.before):this.deep=this.user=this.lazy=this.sync=!1,this.cb=n,this.id=++Nt,this.active=!0,this.dirty=this.lazy,this.deps=[],this.newDeps=[],this.depIds=new ne,this.newDepIds=new ne,this.expression="","function"==typeof t?this.getter=t:(this.getter=function(e){if(!F.test(e)){var t=e.split(".");return function(e){for(var n=0;nOt&&wt[n].id>e.id;)n--;wt.splice(n+1,0,e)}else wt.push(e);At||(At=!0,Ge(Et))}}(this)},jt.prototype.run=function(){if(this.active){var e=this.get();if(e!==this.value||o(e)||this.deep){var t=this.value;if(this.value=e,this.user)try{this.cb.call(this.vm,e,t)}catch(e){Pe(e,this.vm,'callback for watcher "'+this.expression+'"')}else this.cb.call(this.vm,e,t)}}},jt.prototype.evaluate=function(){this.value=this.get(),this.dirty=!1},jt.prototype.depend=function(){for(var e=this.deps.length;e--;)this.deps[e].depend()},jt.prototype.teardown=function(){if(this.active){this.vm._isBeingDestroyed||h(this.vm._watchers,this);for(var e=this.deps.length;e--;)this.deps[e].removeSub(this);this.active=!1}};var Lt={enumerable:!0,configurable:!0,get:S,set:S};function Mt(e,t,n){Lt.get=function(){return this[t][n]},Lt.set=function(e){this[t][n]=e},Object.defineProperty(e,n,Lt)}function It(e){e._watchers=[];var t=e.$options;t.props&&function(e,t){var n=e.$options.propsData||{},r=e._props={},i=e.$options._propKeys=[];e.$parent&&_e(!1);var o=function(o){i.push(o);var a=Le(o,t,n,e);we(r,o,a),o in e||Mt(e,"_props",o)};for(var a in t)o(a);_e(!0)}(e,t.props),t.methods&&function(e,t){e.$options.props;for(var n in t)e[n]="function"!=typeof t[n]?S:x(t[n],e)}(e,t.methods),t.data?function(e){var t=e.$options.data;s(t=e._data="function"==typeof t?function(e,t){ce();try{return e.call(t,t)}catch(e){return Pe(e,t,"data()"),{}}finally{ue()}}(t,e):t||{})||(t={});var n=Object.keys(t),r=e.$options.props,i=(e.$options.methods,n.length);for(;i--;){var o=n[i];r&&y(r,o)||(a=void 0,36!==(a=(o+"").charCodeAt(0))&&95!==a&&Mt(e,"_data",o))}var a;$e(t,!0)}(e):$e(e._data={},!0),t.computed&&function(e,t){var n=e._computedWatchers=Object.create(null),r=Q();for(var i in t){var o=t[i],a="function"==typeof o?o:o.get;r||(n[i]=new jt(e,a||S,S,Dt)),i in e||Pt(e,i,o)}}(e,t.computed),t.watch&&t.watch!==G&&function(e,t){for(var n in t){var r=t[n];if(Array.isArray(r))for(var i=0;i-1:"string"==typeof e?e.split(",").indexOf(t)>-1:(n=e,"[object RegExp]"===a.call(n)&&e.test(t));var n}function wn(e,t){var n=e.cache,r=e.keys,i=e._vnode;for(var o in n){var a=n[o];if(a){var s=bn(a.componentOptions);s&&!t(s)&&Cn(n,o,r,i)}}}function Cn(e,t,n,r){var i=e[t];!i||r&&i.tag===r.tag||i.componentInstance.$destroy(),e[t]=null,h(n,t)}!function(t){t.prototype._init=function(t){var n=this;n._uid=mn++,n._isVue=!0,t&&t._isComponent?function(e,t){var n=e.$options=Object.create(e.constructor.options),r=t._parentVnode;n.parent=t.parent,n._parentVnode=r;var i=r.componentOptions;n.propsData=i.propsData,n._parentListeners=i.listeners,n._renderChildren=i.children,n._componentTag=i.tag,t.render&&(n.render=t.render,n.staticRenderFns=t.staticRenderFns)}(n,t):n.$options=Ne(yn(n.constructor),t||{},n),n._renderProxy=n,n._self=n,function(e){var t=e.$options,n=t.parent;if(n&&!t.abstract){for(;n.$options.abstract&&n.$parent;)n=n.$parent;n.$children.push(e)}e.$parent=n,e.$root=n?n.$root:e,e.$children=[],e.$refs={},e._watcher=null,e._inactive=null,e._directInactive=!1,e._isMounted=!1,e._isDestroyed=!1,e._isBeingDestroyed=!1}(n),function(e){e._events=Object.create(null),e._hasHookEvent=!1;var t=e.$options._parentListeners;t&&dt(e,t)}(n),function(t){t._vnode=null,t._staticTrees=null;var n=t.$options,r=t.$vnode=n._parentVnode,i=r&&r.context;t.$slots=vt(n._renderChildren,i),t.$scopedSlots=e,t._c=function(e,n,r,i){return hn(t,e,n,r,i,!1)},t.$createElement=function(e,n,r,i){return hn(t,e,n,r,i,!0)};var o=r&&r.data;we(t,"$attrs",o&&o.attrs||e,null,!0),we(t,"$listeners",n._parentListeners||e,null,!0)}(n),$t(n,"beforeCreate"),function(e){var t=Bt(e.$options.inject,e);t&&(_e(!1),Object.keys(t).forEach(function(n){we(e,n,t[n])}),_e(!0))}(n),It(n),function(e){var t=e.$options.provide;t&&(e._provided="function"==typeof t?t.call(e):t)}(n),$t(n,"created"),n.$options.el&&n.$mount(n.$options.el)}}(gn),function(e){var t={get:function(){return this._data}},n={get:function(){return this._props}};Object.defineProperty(e.prototype,"$data",t),Object.defineProperty(e.prototype,"$props",n),e.prototype.$set=Ce,e.prototype.$delete=xe,e.prototype.$watch=function(e,t,n){if(s(t))return Ht(this,e,t,n);(n=n||{}).user=!0;var r=new jt(this,e,t,n);if(n.immediate)try{t.call(this,r.value)}catch(e){Pe(e,this,'callback for immediate watcher "'+r.expression+'"')}return function(){r.teardown()}}}(gn),function(e){var t=/^hook:/;e.prototype.$on=function(e,n){var r=this;if(Array.isArray(e))for(var i=0,o=e.length;i1?A(t):t;for(var n=A(arguments,1),r='event handler for "'+e+'"',i=0,o=t.length;iparseInt(this.max)&&Cn(a,s[0],s,this._vnode)),t.data.keepAlive=!0}return t||e&&e[0]}}};!function(e){var t={get:function(){return P}};Object.defineProperty(e,"config",t),e.util={warn:ie,extend:k,mergeOptions:Ne,defineReactive:we},e.set=Ce,e.delete=xe,e.nextTick=Ge,e.observable=function(e){return $e(e),e},e.options=Object.create(null),I.forEach(function(t){e.options[t+"s"]=Object.create(null)}),e.options._base=e,k(e.options.components,An),function(e){e.use=function(e){var t=this._installedPlugins||(this._installedPlugins=[]);if(t.indexOf(e)>-1)return this;var n=A(arguments,1);return n.unshift(this),"function"==typeof e.install?e.install.apply(e,n):"function"==typeof e&&e.apply(null,n),t.push(e),this}}(e),function(e){e.mixin=function(e){return this.options=Ne(this.options,e),this}}(e),_n(e),function(e){I.forEach(function(t){e[t]=function(e,n){return n?("component"===t&&s(n)&&(n.name=n.name||e,n=this.options._base.extend(n)),"directive"===t&&"function"==typeof n&&(n={bind:n,update:n}),this.options[t+"s"][e]=n,n):this.options[t+"s"][e]}})}(e)}(gn),Object.defineProperty(gn.prototype,"$isServer",{get:Q}),Object.defineProperty(gn.prototype,"$ssrContext",{get:function(){return this.$vnode&&this.$vnode.ssrContext}}),Object.defineProperty(gn,"FunctionalRenderContext",{value:an}),gn.version="2.6.1";var kn=p("style,class"),On=p("input,textarea,option,select,progress"),Sn=function(e,t,n){return"value"===n&&On(e)&&"button"!==t||"selected"===n&&"option"===e||"checked"===n&&"input"===e||"muted"===n&&"video"===e},Tn=p("contenteditable,draggable,spellcheck"),En=p("events,caret,typing,plaintext-only"),Nn=function(e,t){return Dn(t)||"false"===t?"false":"contenteditable"===e&&En(t)?t:"true"},jn=p("allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,default,defaultchecked,defaultmuted,defaultselected,defer,disabled,enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,required,reversed,scoped,seamless,selected,sortable,translate,truespeed,typemustmatch,visible"),Ln="http://www.w3.org/1999/xlink",Mn=function(e){return":"===e.charAt(5)&&"xlink"===e.slice(0,5)},In=function(e){return Mn(e)?e.slice(6,e.length):""},Dn=function(e){return null==e||!1===e};function Pn(e){for(var t=e.data,r=e,i=e;n(i.componentInstance);)(i=i.componentInstance._vnode)&&i.data&&(t=Rn(i.data,t));for(;n(r=r.parent);)r&&r.data&&(t=Rn(t,r.data));return function(e,t){if(n(e)||n(t))return Fn(e,Hn(t));return""}(t.staticClass,t.class)}function Rn(e,t){return{staticClass:Fn(e.staticClass,t.staticClass),class:n(e.class)?[e.class,t.class]:t.class}}function Fn(e,t){return e?t?e+" "+t:e:t||""}function Hn(e){return Array.isArray(e)?function(e){for(var t,r="",i=0,o=e.length;i-1?fr(e,t,n):jn(t)?Dn(n)?e.removeAttribute(t):(n="allowfullscreen"===t&&"EMBED"===e.tagName?"true":t,e.setAttribute(t,n)):Tn(t)?e.setAttribute(t,Nn(t,n)):Mn(t)?Dn(n)?e.removeAttributeNS(Ln,In(t)):e.setAttributeNS(Ln,t,n):fr(e,t,n)}function fr(e,t,n){if(Dn(n))e.removeAttribute(t);else{if(J&&!q&&"TEXTAREA"===e.tagName&&"placeholder"===t&&""!==n&&!e.__ieph){var r=function(t){t.stopImmediatePropagation(),e.removeEventListener("input",r)};e.addEventListener("input",r),e.__ieph=!0}e.setAttribute(t,n)}}var pr={create:ur,update:ur};function dr(e,r){var i=r.elm,o=r.data,a=e.data;if(!(t(o.staticClass)&&t(o.class)&&(t(a)||t(a.staticClass)&&t(a.class)))){var s=Pn(r),c=i._transitionClasses;n(c)&&(s=Fn(s,Hn(c))),s!==i._prevClass&&(i.setAttribute("class",s),i._prevClass=s)}}var vr,hr,mr,yr,gr,_r,br={create:dr,update:dr},$r=/[\w).+\-_$\]]/;function wr(e){var t,n,r,i,o,a=!1,s=!1,c=!1,u=!1,l=0,f=0,p=0,d=0;for(r=0;r=0&&" "===(h=e.charAt(v));v--);h&&$r.test(h)||(u=!0)}}else void 0===i?(d=r+1,i=e.slice(0,r).trim()):m();function m(){(o||(o=[])).push(e.slice(d,r).trim()),d=r+1}if(void 0===i?i=e.slice(0,r).trim():0!==d&&m(),o)for(r=0;r-1?{exp:e.slice(0,yr),key:'"'+e.slice(yr+1)+'"'}:{exp:e,key:null};hr=e,yr=gr=_r=0;for(;!Fr();)Hr(mr=Rr())?Ur(mr):91===mr&&Br(mr);return{exp:e.slice(0,gr),key:e.slice(gr+1,_r)}}(e);return null===n.key?e+"="+t:"$set("+n.exp+", "+n.key+", "+t+")"}function Rr(){return hr.charCodeAt(++yr)}function Fr(){return yr>=vr}function Hr(e){return 34===e||39===e}function Br(e){var t=1;for(gr=yr;!Fr();)if(Hr(e=Rr()))Ur(e);else if(91===e&&t++,93===e&&t--,0===t){_r=yr;break}}function Ur(e){for(var t=e;!Fr()&&(e=Rr())!==t;);}var zr,Vr="__r",Kr="__c";function Jr(e,t,n){var r=zr;return function i(){null!==t.apply(null,arguments)&&Wr(e,i,n,r)}}function qr(e,t,n,r){if(Ue){var i=St,o=t;t=o._wrapper=function(e){if(e.timeStamp>=i)return o.apply(this,arguments)}}zr.addEventListener(e,t,X?{capture:n,passive:r}:n)}function Wr(e,t,n,r){(r||zr).removeEventListener(e,t._wrapper||t,n)}function Zr(e,r){if(!t(e.data.on)||!t(r.data.on)){var i=r.data.on||{},o=e.data.on||{};zr=r.elm,function(e){if(n(e[Vr])){var t=J?"change":"input";e[t]=[].concat(e[Vr],e[t]||[]),delete e[Vr]}n(e[Kr])&&(e.change=[].concat(e[Kr],e.change||[]),delete e[Kr])}(i),nt(i,o,qr,Wr,Jr,r.context),zr=void 0}}var Gr,Xr={create:Zr,update:Zr};function Yr(e,r){if(!t(e.data.domProps)||!t(r.data.domProps)){var i,o,a=r.elm,s=e.data.domProps||{},c=r.data.domProps||{};for(i in n(c.__ob__)&&(c=r.data.domProps=k({},c)),s)t(c[i])&&(a[i]="");for(i in c){if(o=c[i],"textContent"===i||"innerHTML"===i){if(r.children&&(r.children.length=0),o===s[i])continue;1===a.childNodes.length&&a.removeChild(a.childNodes[0])}if("value"===i||o!==s[i])if("value"===i){a._value=o;var u=t(o)?"":String(o);Qr(a,u)&&(a.value=u)}else if("innerHTML"===i&&zn(a.tagName)&&t(a.innerHTML)){(Gr=Gr||document.createElement("div")).innerHTML=""+o+"";for(var l=Gr.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}else a[i]=o}}}function Qr(e,t){return!e.composing&&("OPTION"===e.tagName||function(e,t){var n=!0;try{n=document.activeElement!==e}catch(e){}return n&&e.value!==t}(e,t)||function(e,t){var r=e.value,i=e._vModifiers;if(n(i)){if(i.number)return f(r)!==f(t);if(i.trim)return r.trim()!==t.trim()}return r!==t}(e,t))}var ei={create:Yr,update:Yr},ti=g(function(e){var t={},n=/:(.+)/;return e.split(/;(?![^(]*\))/g).forEach(function(e){if(e){var r=e.split(n);r.length>1&&(t[r[0].trim()]=r[1].trim())}}),t});function ni(e){var t=ri(e.style);return e.staticStyle?k(e.staticStyle,t):t}function ri(e){return Array.isArray(e)?O(e):"string"==typeof e?ti(e):e}var ii,oi=/^--/,ai=/\s*!important$/,si=function(e,t,n){if(oi.test(t))e.style.setProperty(t,n);else if(ai.test(n))e.style.setProperty(C(t),n.replace(ai,""),"important");else{var r=ui(t);if(Array.isArray(n))for(var i=0,o=n.length;i-1?t.split(pi).forEach(function(t){return e.classList.add(t)}):e.classList.add(t);else{var n=" "+(e.getAttribute("class")||"")+" ";n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function vi(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(pi).forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t),e.classList.length||e.removeAttribute("class");else{for(var n=" "+(e.getAttribute("class")||"")+" ",r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");(n=n.trim())?e.setAttribute("class",n):e.removeAttribute("class")}}function hi(e){if(e){if("object"==typeof e){var t={};return!1!==e.css&&k(t,mi(e.name||"v")),k(t,e),t}return"string"==typeof e?mi(e):void 0}}var mi=g(function(e){return{enterClass:e+"-enter",enterToClass:e+"-enter-to",enterActiveClass:e+"-enter-active",leaveClass:e+"-leave",leaveToClass:e+"-leave-to",leaveActiveClass:e+"-leave-active"}}),yi=U&&!q,gi="transition",_i="animation",bi="transition",$i="transitionend",wi="animation",Ci="animationend";yi&&(void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(bi="WebkitTransition",$i="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(wi="WebkitAnimation",Ci="webkitAnimationEnd"));var xi=U?window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout:function(e){return e()};function Ai(e){xi(function(){xi(e)})}function ki(e,t){var n=e._transitionClasses||(e._transitionClasses=[]);n.indexOf(t)<0&&(n.push(t),di(e,t))}function Oi(e,t){e._transitionClasses&&h(e._transitionClasses,t),vi(e,t)}function Si(e,t,n){var r=Ei(e,t),i=r.type,o=r.timeout,a=r.propCount;if(!i)return n();var s=i===gi?$i:Ci,c=0,u=function(){e.removeEventListener(s,l),n()},l=function(t){t.target===e&&++c>=a&&u()};setTimeout(function(){c0&&(n=gi,l=a,f=o.length):t===_i?u>0&&(n=_i,l=u,f=c.length):f=(n=(l=Math.max(a,u))>0?a>u?gi:_i:null)?n===gi?o.length:c.length:0,{type:n,timeout:l,propCount:f,hasTransform:n===gi&&Ti.test(r[bi+"Property"])}}function Ni(e,t){for(;e.length1}function Pi(e,t){!0!==t.data.show&&Li(t)}var Ri=function(e){var o,a,s={},c=e.modules,u=e.nodeOps;for(o=0;ov?_(e,t(i[y+1])?null:i[y+1].elm,i,d,y,o):d>y&&$(0,r,p,v)}(p,h,y,o,l):n(y)?(n(e.text)&&u.setTextContent(p,""),_(p,null,y,0,y.length-1,o)):n(h)?$(0,h,0,h.length-1):n(e.text)&&u.setTextContent(p,""):e.text!==i.text&&u.setTextContent(p,i.text),n(v)&&n(d=v.hook)&&n(d=d.postpatch)&&d(e,i)}}}function A(e,t,i){if(r(i)&&n(e.parent))e.parent.data.pendingInsert=t;else for(var o=0;o-1,a.selected!==o&&(a.selected=o);else if(N(zi(a),r))return void(e.selectedIndex!==s&&(e.selectedIndex=s));i||(e.selectedIndex=-1)}}function Ui(e,t){return t.every(function(t){return!N(t,e)})}function zi(e){return"_value"in e?e._value:e.value}function Vi(e){e.target.composing=!0}function Ki(e){e.target.composing&&(e.target.composing=!1,Ji(e.target,"input"))}function Ji(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}function qi(e){return!e.componentInstance||e.data&&e.data.transition?e:qi(e.componentInstance._vnode)}var Wi={model:Fi,show:{bind:function(e,t,n){var r=t.value,i=(n=qi(n)).data&&n.data.transition,o=e.__vOriginalDisplay="none"===e.style.display?"":e.style.display;r&&i?(n.data.show=!0,Li(n,function(){e.style.display=o})):e.style.display=r?o:"none"},update:function(e,t,n){var r=t.value;!r!=!t.oldValue&&((n=qi(n)).data&&n.data.transition?(n.data.show=!0,r?Li(n,function(){e.style.display=e.__vOriginalDisplay}):Mi(n,function(){e.style.display="none"})):e.style.display=r?e.__vOriginalDisplay:"none")},unbind:function(e,t,n,r,i){i||(e.style.display=e.__vOriginalDisplay)}}},Zi={name:String,appear:Boolean,css:Boolean,mode:String,type:String,enterClass:String,leaveClass:String,enterToClass:String,leaveToClass:String,enterActiveClass:String,leaveActiveClass:String,appearClass:String,appearActiveClass:String,appearToClass:String,duration:[Number,String,Object]};function Gi(e){var t=e&&e.componentOptions;return t&&t.Ctor.options.abstract?Gi(ut(t.children)):e}function Xi(e){var t={},n=e.$options;for(var r in n.propsData)t[r]=e[r];var i=n._parentListeners;for(var o in i)t[b(o)]=i[o];return t}function Yi(e,t){if(/\d-keep-alive$/.test(t.tag))return e("keep-alive",{props:t.componentOptions.propsData})}var Qi=function(e){return e.tag||ct(e)},eo=function(e){return"show"===e.name},to={name:"transition",props:Zi,abstract:!0,render:function(e){var t=this,n=this.$slots.default;if(n&&(n=n.filter(Qi)).length){var r=this.mode,o=n[0];if(function(e){for(;e=e.parent;)if(e.data.transition)return!0}(this.$vnode))return o;var a=Gi(o);if(!a)return o;if(this._leaving)return Yi(e,o);var s="__transition-"+this._uid+"-";a.key=null==a.key?a.isComment?s+"comment":s+a.tag:i(a.key)?0===String(a.key).indexOf(s)?a.key:s+a.key:a.key;var c=(a.data||(a.data={})).transition=Xi(this),u=this._vnode,l=Gi(u);if(a.data.directives&&a.data.directives.some(eo)&&(a.data.show=!0),l&&l.data&&!function(e,t){return t.key===e.key&&t.tag===e.tag}(a,l)&&!ct(l)&&(!l.componentInstance||!l.componentInstance._vnode.isComment)){var f=l.data.transition=k({},c);if("out-in"===r)return this._leaving=!0,rt(f,"afterLeave",function(){t._leaving=!1,t.$forceUpdate()}),Yi(e,o);if("in-out"===r){if(ct(a))return u;var p,d=function(){p()};rt(c,"afterEnter",d),rt(c,"enterCancelled",d),rt(f,"delayLeave",function(e){p=e})}}return o}}},no=k({tag:String,moveClass:String},Zi);function ro(e){e.elm._moveCb&&e.elm._moveCb(),e.elm._enterCb&&e.elm._enterCb()}function io(e){e.data.newPos=e.elm.getBoundingClientRect()}function oo(e){var t=e.data.pos,n=e.data.newPos,r=t.left-n.left,i=t.top-n.top;if(r||i){e.data.moved=!0;var o=e.elm.style;o.transform=o.WebkitTransform="translate("+r+"px,"+i+"px)",o.transitionDuration="0s"}}delete no.mode;var ao={Transition:to,TransitionGroup:{props:no,beforeMount:function(){var e=this,t=this._update;this._update=function(n,r){var i=gt(e);e.__patch__(e._vnode,e.kept,!1,!0),e._vnode=e.kept,i(),t.call(e,n,r)}},render:function(e){for(var t=this.tag||this.$vnode.data.tag||"span",n=Object.create(null),r=this.prevChildren=this.children,i=this.$slots.default||[],o=this.children=[],a=Xi(this),s=0;s-1?Jn[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:Jn[e]=/HTMLUnknownElement/.test(t.toString())},k(gn.options.directives,Wi),k(gn.options.components,ao),gn.prototype.__patch__=U?Ri:S,gn.prototype.$mount=function(e,t){return function(e,t,n){var r;return e.$el=t,e.$options.render||(e.$options.render=pe),$t(e,"beforeMount"),r=function(){e._update(e._render(),n)},new jt(e,r,S,{before:function(){e._isMounted&&!e._isDestroyed&&$t(e,"beforeUpdate")}},!0),n=!1,null==e.$vnode&&(e._isMounted=!0,$t(e,"mounted")),e}(this,e=e&&U?Wn(e):void 0,t)},U&&setTimeout(function(){P.devtools&&ee&&ee.emit("init",gn)},0);var so=/\{\{((?:.|\r?\n)+?)\}\}/g,co=/[-.*+?^${}()|[\]\/\\]/g,uo=g(function(e){var t=e[0].replace(co,"\\$&"),n=e[1].replace(co,"\\$&");return new RegExp(t+"((?:.|\\n)+?)"+n,"g")});var lo={staticKeys:["staticClass"],transformNode:function(e,t){t.warn;var n=Lr(e,"class");n&&(e.staticClass=JSON.stringify(n));var r=jr(e,"class",!1);r&&(e.classBinding=r)},genData:function(e){var t="";return e.staticClass&&(t+="staticClass:"+e.staticClass+","),e.classBinding&&(t+="class:"+e.classBinding+","),t}};var fo,po={staticKeys:["staticStyle"],transformNode:function(e,t){t.warn;var n=Lr(e,"style");n&&(e.staticStyle=JSON.stringify(ti(n)));var r=jr(e,"style",!1);r&&(e.styleBinding=r)},genData:function(e){var t="";return e.staticStyle&&(t+="staticStyle:"+e.staticStyle+","),e.styleBinding&&(t+="style:("+e.styleBinding+"),"),t}},vo=function(e){return(fo=fo||document.createElement("div")).innerHTML=e,fo.textContent},ho=p("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),mo=p("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),yo=p("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track"),go=/^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,_o=/^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,bo="[a-zA-Z_][\\-\\.0-9_a-zA-Za-zA-Z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c-\u200d\u203f-\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]*",$o="((?:"+bo+"\\:)?"+bo+")",wo=new RegExp("^<"+$o),Co=/^\s*(\/?)>/,xo=new RegExp("^<\\/"+$o+"[^>]*>"),Ao=/^]+>/i,ko=/^",""":'"',"&":"&"," ":"\n"," ":"\t","'":"'"},No=/&(?:lt|gt|quot|amp|#39);/g,jo=/&(?:lt|gt|quot|amp|#39|#10|#9);/g,Lo=p("pre,textarea",!0),Mo=function(e,t){return e&&Lo(e)&&"\n"===t[0]};function Io(e,t){var n=t?jo:No;return e.replace(n,function(e){return Eo[e]})}var Do,Po,Ro,Fo,Ho,Bo,Uo,zo,Vo=/^@|^v-on:/,Ko=/^v-|^@|^:/,Jo=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,qo=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,Wo=/^\(|\)$/g,Zo=/^\[.*\]$/,Go=/:(.*)$/,Xo=/^:|^\.|^v-bind:/,Yo=/\.[^.]+/g,Qo=/^v-slot(:|$)|^#/,ea=/[\r\n]/,ta=/\s+/g,na=g(vo);function ra(e,t,n){return{type:1,tag:e,attrsList:t,attrsMap:la(t),rawAttrsMap:{},parent:n,children:[]}}function ia(e,t){Do=t.warn||xr,Bo=t.isPreTag||T,Uo=t.mustUseProp||T,zo=t.getTagNamespace||T;t.isReservedTag;Ro=Ar(t.modules,"transformNode"),Fo=Ar(t.modules,"preTransformNode"),Ho=Ar(t.modules,"postTransformNode"),Po=t.delimiters;var n,r,i=[],o=!1!==t.preserveWhitespace,a=t.whitespace,s=!1,c=!1;function u(e){if(l(e),s||e.processed||(e=oa(e,t)),i.length||e===n||n.if&&(e.elseif||e.else)&&sa(n,{exp:e.elseif,block:e}),r&&!e.forbidden)if(e.elseif||e.else)a=e,(u=function(e){var t=e.length;for(;t--;){if(1===e[t].type)return e[t];e.pop()}}(r.children))&&u.if&&sa(u,{exp:a.elseif,block:a});else{if(e.slotScope){var o=e.slotTarget||'"default"';(r.scopedSlots||(r.scopedSlots={}))[o]=e}r.children.push(e),e.parent=r}var a,u;e.children=e.children.filter(function(e){return!e.slotScope}),l(e),e.pre&&(s=!1),Bo(e.tag)&&(c=!1);for(var f=0;f]*>)","i")),p=e.replace(f,function(e,n,r){return u=r.length,So(l)||"noscript"===l||(n=n.replace(//g,"$1").replace(//g,"$1")),Mo(l,n)&&(n=n.slice(1)),t.chars&&t.chars(n),""});c+=e.length-p.length,e=p,k(l,c-u,c)}else{var d=e.indexOf("<");if(0===d){if(ko.test(e)){var v=e.indexOf("--\x3e");if(v>=0){t.shouldKeepComment&&t.comment(e.substring(4,v),c,c+v+3),C(v+3);continue}}if(Oo.test(e)){var h=e.indexOf("]>");if(h>=0){C(h+2);continue}}var m=e.match(Ao);if(m){C(m[0].length);continue}var y=e.match(xo);if(y){var g=c;C(y[0].length),k(y[1],g,c);continue}var _=x();if(_){A(_),Mo(_.tagName,e)&&C(1);continue}}var b=void 0,$=void 0,w=void 0;if(d>=0){for($=e.slice(d);!(xo.test($)||wo.test($)||ko.test($)||Oo.test($)||(w=$.indexOf("<",1))<0);)d+=w,$=e.slice(d);b=e.substring(0,d)}d<0&&(b=e),b&&C(b.length),t.chars&&b&&t.chars(b,c-b.length,c)}if(e===n){t.chars&&t.chars(e);break}}function C(t){c+=t,e=e.substring(t)}function x(){var t=e.match(wo);if(t){var n,r,i={tagName:t[1],attrs:[],start:c};for(C(t[0].length);!(n=e.match(Co))&&(r=e.match(_o)||e.match(go));)r.start=c,C(r[0].length),r.end=c,i.attrs.push(r);if(n)return i.unarySlash=n[1],C(n[0].length),i.end=c,i}}function A(e){var n=e.tagName,c=e.unarySlash;o&&("p"===r&&yo(n)&&k(r),s(n)&&r===n&&k(n));for(var u=a(n)||!!c,l=e.attrs.length,f=new Array(l),p=0;p=0&&i[a].lowerCasedTag!==s;a--);else a=0;if(a>=0){for(var u=i.length-1;u>=a;u--)t.end&&t.end(i[u].tag,n,o);i.length=a,r=a&&i[a-1].tag}else"br"===s?t.start&&t.start(e,[],!0,n,o):"p"===s&&(t.start&&t.start(e,[],!1,n,o),t.end&&t.end(e,n,o))}k()}(e,{warn:Do,expectHTML:t.expectHTML,isUnaryTag:t.isUnaryTag,canBeLeftOpenTag:t.canBeLeftOpenTag,shouldDecodeNewlines:t.shouldDecodeNewlines,shouldDecodeNewlinesForHref:t.shouldDecodeNewlinesForHref,shouldKeepComment:t.comments,outputSourceRange:t.outputSourceRange,start:function(e,o,a,l){var f=r&&r.ns||zo(e);J&&"svg"===f&&(o=function(e){for(var t=[],n=0;nc&&(s.push(o=e.slice(c,i)),a.push(JSON.stringify(o)));var u=wr(r[1].trim());a.push("_s("+u+")"),s.push({"@binding":u}),c=i+r[0].length}return c-1"+("true"===o?":("+t+")":":_q("+t+","+o+")")),Nr(e,"change","var $$a="+t+",$$el=$event.target,$$c=$$el.checked?("+o+"):("+a+");if(Array.isArray($$a)){var $$v="+(r?"_n("+i+")":i)+",$$i=_i($$a,$$v);if($$el.checked){$$i<0&&("+Pr(t,"$$a.concat([$$v])")+")}else{$$i>-1&&("+Pr(t,"$$a.slice(0,$$i).concat($$a.slice($$i+1))")+")}}else{"+Pr(t,"$$c")+"}",null,!0)}(e,r,i);else if("input"===o&&"radio"===a)!function(e,t,n){var r=n&&n.number,i=jr(e,"value")||"null";kr(e,"checked","_q("+t+","+(i=r?"_n("+i+")":i)+")"),Nr(e,"change",Pr(t,i),null,!0)}(e,r,i);else if("input"===o||"textarea"===o)!function(e,t,n){var r=e.attrsMap.type,i=n||{},o=i.lazy,a=i.number,s=i.trim,c=!o&&"range"!==r,u=o?"change":"range"===r?Vr:"input",l="$event.target.value";s&&(l="$event.target.value.trim()"),a&&(l="_n("+l+")");var f=Pr(t,l);c&&(f="if($event.target.composing)return;"+f),kr(e,"value","("+t+")"),Nr(e,u,f,null,!0),(s||a)&&Nr(e,"blur","$forceUpdate()")}(e,r,i);else if(!P.isReservedTag(o))return Dr(e,r,i),!1;return!0},text:function(e,t){t.value&&kr(e,"textContent","_s("+t.value+")",t)},html:function(e,t){t.value&&kr(e,"innerHTML","_s("+t.value+")",t)}},isPreTag:function(e){return"pre"===e},isUnaryTag:ho,mustUseProp:Sn,canBeLeftOpenTag:mo,isReservedTag:Vn,getTagNamespace:Kn,staticKeys:function(e){return e.reduce(function(e,t){return e.concat(t.staticKeys||[])},[]).join(",")}(va)},ga=g(function(e){return p("type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap"+(e?","+e:""))});function _a(e,t){e&&(ha=ga(t.staticKeys||""),ma=t.isReservedTag||T,function e(t){t.static=function(e){if(2===e.type)return!1;if(3===e.type)return!0;return!(!e.pre&&(e.hasBindings||e.if||e.for||d(e.tag)||!ma(e.tag)||function(e){for(;e.parent;){if("template"!==(e=e.parent).tag)return!1;if(e.for)return!0}return!1}(e)||!Object.keys(e).every(ha)))}(t);if(1===t.type){if(!ma(t.tag)&&"slot"!==t.tag&&null==t.attrsMap["inline-template"])return;for(var n=0,r=t.children.length;n|^function\s*\(/,$a=/\([^)]*?\);*$/,wa=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/,Ca={esc:27,tab:9,enter:13,space:32,up:38,left:37,right:39,down:40,delete:[8,46]},xa={esc:["Esc","Escape"],tab:"Tab",enter:"Enter",space:[" ","Spacebar"],up:["Up","ArrowUp"],left:["Left","ArrowLeft"],right:["Right","ArrowRight"],down:["Down","ArrowDown"],delete:["Backspace","Delete","Del"]},Aa=function(e){return"if("+e+")return null;"},ka={stop:"$event.stopPropagation();",prevent:"$event.preventDefault();",self:Aa("$event.target !== $event.currentTarget"),ctrl:Aa("!$event.ctrlKey"),shift:Aa("!$event.shiftKey"),alt:Aa("!$event.altKey"),meta:Aa("!$event.metaKey"),left:Aa("'button' in $event && $event.button !== 0"),middle:Aa("'button' in $event && $event.button !== 1"),right:Aa("'button' in $event && $event.button !== 2")};function Oa(e,t){var n=t?"nativeOn:":"on:",r="",i="";for(var o in e){var a=Sa(e[o]);e[o]&&e[o].dynamic?i+=o+","+a+",":r+='"'+o+'":'+a+","}return r="{"+r.slice(0,-1)+"}",i?n+"_d("+r+",["+i.slice(0,-1)+"])":n+r}function Sa(e){if(!e)return"function(){}";if(Array.isArray(e))return"["+e.map(function(e){return Sa(e)}).join(",")+"]";var t=wa.test(e.value),n=ba.test(e.value),r=wa.test(e.value.replace($a,""));if(e.modifiers){var i="",o="",a=[];for(var s in e.modifiers)if(ka[s])o+=ka[s],Ca[s]&&a.push(s);else if("exact"===s){var c=e.modifiers;o+=Aa(["ctrl","shift","alt","meta"].filter(function(e){return!c[e]}).map(function(e){return"$event."+e+"Key"}).join("||"))}else a.push(s);return a.length&&(i+=function(e){return"if(('keyCode' in $event)&&"+e.map(Ta).join("&&")+")return null;"}(a)),o&&(i+=o),"function($event){"+i+(t?"return "+e.value+"($event)":n?"return ("+e.value+")($event)":r?"return "+e.value:e.value)+"}"}return t||n?e.value:"function($event){"+(r?"return "+e.value:e.value)+"}"}function Ta(e){var t=parseInt(e,10);if(t)return"$event.keyCode!=="+t;var n=Ca[e],r=xa[e];return"_k($event.keyCode,"+JSON.stringify(e)+","+JSON.stringify(n)+",$event.key,"+JSON.stringify(r)+")"}var Ea={on:function(e,t){e.wrapListeners=function(e){return"_g("+e+","+t.value+")"}},bind:function(e,t){e.wrapData=function(n){return"_b("+n+",'"+e.tag+"',"+t.value+","+(t.modifiers&&t.modifiers.prop?"true":"false")+(t.modifiers&&t.modifiers.sync?",true":"")+")"}},cloak:S},Na=function(e){this.options=e,this.warn=e.warn||xr,this.transforms=Ar(e.modules,"transformCode"),this.dataGenFns=Ar(e.modules,"genData"),this.directives=k(k({},Ea),e.directives);var t=e.isReservedTag||T;this.maybeComponent=function(e){return!!e.component||!t(e.tag)},this.onceId=0,this.staticRenderFns=[],this.pre=!1};function ja(e,t){var n=new Na(t);return{render:"with(this){return "+(e?La(e,n):'_c("div")')+"}",staticRenderFns:n.staticRenderFns}}function La(e,t){if(e.parent&&(e.pre=e.pre||e.parent.pre),e.staticRoot&&!e.staticProcessed)return Ma(e,t);if(e.once&&!e.onceProcessed)return Ia(e,t);if(e.for&&!e.forProcessed)return Pa(e,t);if(e.if&&!e.ifProcessed)return Da(e,t);if("template"!==e.tag||e.slotTarget||t.pre){if("slot"===e.tag)return function(e,t){var n=e.slotName||'"default"',r=Ha(e,t),i="_t("+n+(r?","+r:""),o=e.attrs&&"{"+e.attrs.map(function(e){return b(e.name)+":"+e.value}).join(",")+"}",a=e.attrsMap["v-bind"];!o&&!a||r||(i+=",null");o&&(i+=","+o);a&&(i+=(o?"":",null")+","+a);return i+")"}(e,t);var n;if(e.component)n=function(e,t,n){var r=t.inlineTemplate?null:Ha(t,n,!0);return"_c("+e+","+Ra(t,n)+(r?","+r:"")+")"}(e.component,e,t);else{var r;(!e.plain||e.pre&&t.maybeComponent(e))&&(r=Ra(e,t));var i=e.inlineTemplate?null:Ha(e,t,!0);n="_c('"+e.tag+"'"+(r?","+r:"")+(i?","+i:"")+")"}for(var o=0;o':'
',Wa.innerHTML.indexOf(" ")>0}var Ya=!!U&&Xa(!1),Qa=!!U&&Xa(!0),es=g(function(e){var t=Wn(e);return t&&t.innerHTML}),ts=gn.prototype.$mount;return gn.prototype.$mount=function(e,t){if((e=e&&Wn(e))===document.body||e===document.documentElement)return this;var n=this.$options;if(!n.render){var r=n.template;if(r)if("string"==typeof r)"#"===r.charAt(0)&&(r=es(r));else{if(!r.nodeType)return this;r=r.innerHTML}else e&&(r=function(e){if(e.outerHTML)return e.outerHTML;var t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML}(e));if(r){var i=Ga(r,{outputSourceRange:!1,shouldDecodeNewlines:Ya,shouldDecodeNewlinesForHref:Qa,delimiters:n.delimiters,comments:n.comments},this),o=i.render,a=i.staticRenderFns;n.render=o,n.staticRenderFns=a}}return ts.call(this,e,t)},gn.compile=Ga,gn}); // 初始化 function initialize() { let defaultWords = { "key_123": { limit: ["baidu"], "info": "汉字", "words": ["抖音", "快手", "网页", "平台", "的", "最", "一", "个", "多", "服务", "大"], "color": "#85d228" }, "key_124": { limit: [], "info": "数字", "words": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"], "color": "#48c790" }, "key_3379656389": { limit: [], "info": "字母", "words": ["a", "b", "c", "d", "e", "f", "t", "y", "u", "i", "o", "k", "j", "h", "g", "s", "z", "x", "v", "n", "m"], "color": "#e33544" }, "key_4947181948": { limit: [], "info": "相同的字可以显示各个分组的标题", "words": ["的", "最", "一", "个", "多", "服务", "大"], "color": "#6e7bdd" } } // 设置关键字默认值 if (!GM_getValue("key")) { GM_setValue("key", defaultWords) } if (Object.keys(GM_getValue("key")).length == 0) { GM_setValue("key", defaultWords) } // GM_setValue("key",this.defaultWords); let cache = GM_getValue("key") Object.keys(cache).forEach(key => { let defult = { limit: [], info: "", words: [], color: "#85d228" } Object.keys(defult).forEach((key2) => { if (!cache[key][key2]) { console.log(defult[key2]); cache[key][key2] = defult[key2] } }) }) GM_setValue("key", cache) } /** * @description: 遍历找出所有文本节点 * @param {*} node * @return {*} 节点map */ function textMap(node) { // 存储文本节点 let nodeMap = new Map() const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT, (textNode) => { if (textNode.parentElement.nodeName === "SCRIPT" | textNode.parentElement.nodeName === "script" | textNode.parentElement.nodeName === "style" | textNode.parentElement.nodeName === "STYLE" | textNode.parentElement.className === "mt_highlight" | document.querySelector("#mt_seting_box").contains(textNode) ) { return NodeFilter.FILTER_SKIP } if (textNode.data.length < 20) { return textNode.data.replace(/[\n \t]/g, "").length ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP } return NodeFilter.FILTER_ACCEPT }) while ((textNode = walker.nextNode())) { nodeMap.set(textNode, textNode.data) } return nodeMap } // 高亮 class HIGHTLIGHT { // 需要高亮的关键字 /**通过规则新建关键字列表,解决一个关键字会存在多个分类中 * 将{ * key1{ * words:[word1,word2] * }, * key2{ * words:[word3,word4] * } * } * 转换为map{ * word1:key1 * word2:key1 * word4:key2 * word3:key2 * } * @description: * @return {map}map{ * * classesKey=>分类标签,类型string * * infoList=>提示词,数组["汉字","字符"] * * } */ static words() { // 转换 let newWords = new Map Object.keys(GM_getValue("key")).forEach(classesKey => { let info = GM_getValue("key")[classesKey].info let words = GM_getValue("key")[classesKey].words let color = GM_getValue("key")[classesKey].color let limit = GM_getValue("key")[classesKey].limit words.forEach(word => { let infoList = [] // 检测是否被多个类目包含,被多个类目包含的关键字会有对应类目的信息 if (newWords.get(word + "")) { infoList = newWords.get(word + "").infoList infoList.push(info) } else { infoList = [info] } newWords.set(word + "", { classesKey, infoList: infoList, color, limit }) }) }) return newWords } // 检测正则 static reg() { let url = window.location.href let doIt = false let wordsList = [] let words = this.words() words.forEach((value, word) => { // console.log(value.limit); // 过滤不匹配的 if (value.limit.length == 0 || url.match(new RegExp(`${value.limit.join("|")}`, "g"))) { // 添加要筛选的关键字 wordsList.push(word) } }) // 过滤后还需不需要检测 wordsList.length ? doIt = true : doIt = false // console.log(doIt,wordsList); return { rule: new RegExp(`(${wordsList.join("|")})`, "g"), doIt } } // 高亮css static highlightStyle = ` .mt_highlight{ background-color: rgb(255, 21, 21); border-radius: 2px; box-shadow: 0px 0px 1px 1px rgba(0, 0, 0,0.1); cursor: pointer; color: white; padding: 1px 1px; } ` /** * @description: 返回需要被高亮的节点map{textNode,未来会被修改成目标的值} * @param {map} nodeMap * @return {void} */ static highlight(nodeMap) { let words = this.words() let reg = this.reg() // 没有要高亮的关键字时不执行 if (words.size && reg.doIt) { nodeMap.forEach((value, node) => { // 正则检测是否符合规则 let newInnerHTML = value.replace(reg.rule, (word) => { let classesKey = words.get(word).classesKey let infoList = words.get(word).infoList let color = words.get(word).color // 返回新节点模板 return `${word}` }) // 是否检测出了 if (value != newInnerHTML) { // 节点替换 let newNode = document.createElement("span") newNode.innerHTML = newInnerHTML node.parentElement.replaceChild(newNode, node) // 点击复制 newNode.addEventListener("click", (e) => { navigator.clipboard.writeText(e.target.innerText); }) } }) } } } /** * @description: 动态检测新节点,并执行高亮 * @return {*} */ function watch() { // 选择需要观察变动的节点 const targetNode = document.body; // 观察器的配置(需要观察什么变动) const config = { attributes: false, childList: true, subtree: true, characterData: true }; // 当观察到变动时执行的回调函数 const callback = function (mutationsList, observer) { let nodeMap = new Map setTimeout(() => { mutationsList.forEach(node => { nodeMap.set(node.target) }) nodeMap.forEach((value, node) => { doOnce(node) }) }, 1); }; // 创建一个观察器实例并传入回调函数 const observer = new MutationObserver(callback); // 以上述配置开始观察目标节点 observer.observe(targetNode, config); } // gui class GUI { // 模板 static setingTemplate = String.raw`
导入添加
导入覆盖
导出配置文件
刷新
关闭
{{word}} 不限制
{{value.info}}
{{word}}
删除
取消
确定
+
` // 模板css static setingStyle = ` body { --mian_width: 480px; --mian_color: #189fd8; --radius: 5px; --info_color: #eaeaea; --font_color: #676767; } .seting_box { width: 500px; max-height: 800px; overflow: auto; background: white; border-radius: 5px; position: fixed; transform: translate(-50%, 0); top: 50px; left: 50%; border: 1px solid rgba(0, 0, 0, 0.1); padding: 15px 5px; flex-direction: column; align-items: center; z-index: 10000; display: flex; box-shadow: 0 1px 5px 5px rgba(0, 0, 0, 0.1); } .option_box { width: var(--mian_width); display: flex; justify-content: space-between; } .option_box div { display: flex; height: 20px; align-items: center; padding: 5px 10px; background: var(--mian_color); color: white; border-radius: var(--radius); cursor: pointer; } .rule_list_box { width: var(--mian_width); border-radius: var(--radius); margin-top: 10px; padding: 5px 0px; box-shadow: 0 0 5px 0px #e2e2e2; cursor: pointer; } .rule_list_box .show_box { display: flex; justify-content: space-between; } .rule_list_box .show_box .show_left { width: 410px; } .rule_list_box .show_box .show_left > div { margin-top: 5px; } .rule_list_box .show_box .show_left > div:nth-child(1) { margin-top: 0px; } .rule_list_box .show_box .show_left .info_box { margin-left: 5px; margin-right: 5px; padding: 2px 5px; min-height: 22px; color: white; border-radius: var(--radius); background-color: var(--mian_color); display: flex; align-items: center; } .rule_list_box .show_box .show_left .words_box { margin-top: 0px; /* border: 1px solid black; */ min-height: 20px; display: flex; flex-wrap: wrap; } .rule_list_box .show_box .show_left .words_box span { background-color: var(--info_color); color: white; padding: 2px 5px; border-radius: var(--radius); margin-left: 5px; margin-top: 5px; display: flex; align-items: center; height: 20px; } .rule_list_box .show_box .rule_set_box { display: flex; flex-direction: column; justify-content: space-around; padding: 0px 5px; } .rule_list_box .show_box .rule_set_box .color_box { overflow: hidden; display: flex; justify-content: center; align-items: center; } .rule_list_box .show_box .rule_set_box .color_box input { width: 50px; height: 25px; border-radius: var(--radius) !important; padding: 0px; } .rule_list_box .eidt_box { padding: 0px 5px; display: flex; flex-direction: row; justify-content: space-between; } .rule_list_box .eidt_box .eidt_left { width: 400px; } .rule_list_box .eidt_box .eidt_left textarea { width: 100% !important; min-height: 30px !important; border: none; outline: none; color: var(--font_color); background-color: var(--info_color); border-radius: var(--radius); margin-top: 5px; padding: 5px; } .rule_list_box .eidt_box .eidt_left textarea:nth-child(1) { margin-top: 0px; } .rule_list_box .eidt_box .eidt_right { display: flex; flex-direction: column; justify-content: space-around; } .rule_list_box .line { width: 1px; background-color: rgba(0, 0, 0, 0.1); } .rule_list_box .del { background-color: var(--mian_color); color: white; border-radius: var(--radius); padding: 0px 10px; font-size: 15px; display: flex; justify-content: center; align-items: center; cursor: pointer; } .add { width: var(--mian_width); height: 30px; background: #189fd8; color: white; display: flex; justify-content: center; border-radius: 5px; padding: 5px 0px; margin-top: 10px; align-items: center; font-size: 35px; font-weight: 100; cursor: pointer; } .bt { display: flex; align-items: center; justify-content: space-around; } input { border: none; padding: 0px; border-radius: 5px; box-shadow: none; } .config_file { display: none; } ` // 开发用 static devCss() { GM_xmlhttpRequest({ method: "get", url: "http://127.0.0.1:1145", responseType: "blob", onload: (res) => { // console.log(res.responseText); GM_addStyle(res.responseText) }, onerror: (error => { console.log("该页无法链接"); }) }) } static create() { // 获取根节点 let seting_box = document.querySelector("#mt_seting_box") seting_box.innerHTML = this.setingTemplate // 创建根节点样式 GM_addStyle(this.setingStyle) // this.devCss() // 创建响应式ui const mt_Vue = new Vue({ el: "#mt_seting_box", data() { return { rule: GM_getValue("key"), edit: this.addEdit(GM_getValue("key")), showSeting: false, config_add: false } }, watch: { showSeting(n) { // console.log(22333); } }, methods: { // 关闭设置 close_seting() { this.showSeting = false }, // 开启设置 open_seting() { this.showSeting = true console.log(2233); }, // 添加属性开关 addEdit(rules) { let a = {} Object.keys(rules).forEach(key => { a[key] = false }) return a }, // 打开编辑 editOn(key) { this.edit[key] = true }, // 关闭编辑 editOff(key) { this.edit[key] = false }, // 颜色更新 colorChange(key, color) { document.querySelectorAll(`.mt_highlight[classesKey="${key}"]`).forEach(node => { node.style.background = color }) // 保存到油猴中 GM_setValue("key", this.rule) }, // 更新规则 ruleUpdate(key) { let newInfo = document.querySelector(`textarea[info_key=${key}]`).value let newWords = (document.querySelector(`textarea[words_key=${key}]`).value.split(" ")) let newLimit = (document.querySelector(`textarea[limit_key=${key}]`).value.split(" ")) // 去除空格 newWords = Array.from(new Set(newWords)) .filter(word => { return word != " " & word.length > 0 }) newLimit = Array.from(new Set(newLimit)) .filter(word => { return word != " " & word.length > 0 }) // console.log(newInfo,newWords); this.rule[key].info = newInfo this.rule[key].words = newWords this.rule[key].limit = newLimit this.editOff(key) // 保存到油猴中 GM_setValue("key", this.rule) }, // 添加新规则 add_key() { let key = "key_" + Math.floor(Math.random() * 10000000000) this.$set(this.rule, key, { info: "", words: [], color: "#dc6c75", limit: [] }) this.$set(this.edit, key, false) // 保存到油猴中 GM_setValue("key", this.rule) console.log(2233); }, // 删除规则 del_key(key) { let ready = confirm("确认删除,该操作不可恢复") if (ready && Object.keys(this.rule).length > 1) { this.$delete(this.rule, key) this.$delete(this.edit, key) } else if (ready && Object.keys(this.rule).length < 2) { alert("至少保留一个") } // 保存到油猴中 GM_setValue("key", this.rule) }, // 复制到粘贴板 copy() { navigator.clipboard.writeText(JSON.stringify(this.rules)); }, // 获取配置覆盖 config_in() { document.querySelector(".config_file").click() this.config_add = false }, // 获取配置添加 config_in_add() { document.querySelector(".config_file").click() this.config_add = true }, // 解析配置 importFileJSON(ev) { return new Promise((resolve, reject) => { const fileDom = ev.target, file = fileDom.files[0]; // 格式判断 if (file.type !== 'application/json') { reject('仅允许上传json文件'); } // 检验是否支持FileRender if (typeof FileReader === 'undefined') { reject('当前浏览器不支持FileReader'); } // 执行后清空input的值,防止下次选择同一个文件不会触发onchange事件 ev.target.value = ''; // 执行读取json数据操作 const reader = new FileReader(); reader.readAsText(file); // 读取的结果还有其他读取方式,我认为text最为方便 reader.onerror = (err) => { reject('json文件解析失败', err); } reader.onload = () => { const resultData = reader.result; if (resultData) { try { const importData = JSON.parse(resultData); resolve(importData); } catch (error) { reject('读取数据解析失败', error); } } else { reject('读取数据解析失败', error); } } }) }, // 保存配置到本地 file_read(e) { this.importFileJSON(e).then(res => { // 合并还是覆盖 if (this.config_add) { let cache = {} Object.keys(GM_getValue("key")).forEach(key => { cache["key_" + Math.floor(Math.random() * 10000000000)] = GM_getValue("key")[key] }) cache = { ...cache, ...res } console.log(cache); GM_setValue("key", cache) } else { GM_setValue("key", res) } initialize() this.rule = GM_getValue("key") this.edit = this.addEdit(res) }) }, // 导出配置 config_out() { function exportJson(name, data) { let blob = new Blob([data]); // 创建 blob 对象 let link = document.createElement("a"); link.href = URL.createObjectURL(blob); // 创建一个 URL 对象并传给 a 的 href link.download = name; // 设置下载的默认文件名 link.click(); } exportJson("mt_hight_light_config.json", JSON.stringify(this.rule)) }, // 刷新 refresh() { location.reload(); }, }, mounted() { GM_registerMenuCommand("打开设置", this.open_seting); // 点击其他区域关闭设置 document.body.addEventListener("click", (e) => { if (!document.querySelector("#mt_seting_box").contains(e.target)) { this.close_seting() } }) }, }) } } /////////////////////////////////////////////////////////// // vue根节点 let seting_box = document.createElement("div"); // 创建一个节点 seting_box.setAttribute("id", "mt_seting_box"); // 设置一个属性 document.body.appendChild(seting_box) GM_addStyle(HIGHTLIGHT.highlightStyle) // 初始化数据 initialize() console.log(GM_getValue("key")); // 静态页面的检测 let nodeMap = textMap(document.body) // console.log(nodeMap); HIGHTLIGHT.highlight(nodeMap) nodeMap.clear() // 减少节点的重复检测 let doOnce = ((wait) => { let timer = null; // 存储动态更新的节点 let elMap = new Map return (el) => { // 添加节点 elMap.set(el) if (!timer) { timer = setTimeout(() => { // console.log(elMap); elMap.forEach((value, el) => { setTimeout(() => { let nodeMap = textMap(el) HIGHTLIGHT.highlight(nodeMap) nodeMap = null }, 1); }) elMap.clear() timer = null }, wait); } } })(100) // 动态更新内容的检测 watch() // 创建ui GUI.create() } )()