自用
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/438011/1005018/%E5%BA%93.js
// ==UserScript==
// @name 库
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 自用
// @author Mr Liu
// @match *
// @grant none
// @require https://cdn.bootcss.com/jquery/3.6.0/jquery.min.js
// ==/UserScript==
function Input(ele,val){//键盘输入函数 可调用
ele.value = val;
let event = new Event('input', { bubbles: true });
let tracker = ele._valueTracker;
if (tracker) {
tracker.setValue('');
}
ele.dispatchEvent(event);
}
function ysjt(fun){//元素监听
const url=window.location.href
const targetNode = $('.ant-layout')[0];//content监听的元素id
//options:监听的属性
const options = { attributes: true, childList: true,subtree:true,attributeOldValue:true};
//回调事件
const mutationObserver = new MutationObserver(()=>{
if(window.location.href!=url){
fun()//要执行的
}
});
mutationObserver.observe(targetNode, options)
}
function mdjt(fun){//锚点监听 检测url变化
window.onpopstate = function (event) {
fun();
}
}