自用

目前為 2022-01-04 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/438011/1005018/%E5%BA%93.js

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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();
    }
}