Web按鈕注入

向頁面注入一個按鈕並進行函數綁定

Tính đến 26-10-2022. Xem phiên bản mới nhất.

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greasyfork.org/scripts/453745/1109529/Web%E6%8C%89%E9%88%95%E6%B3%A8%E5%85%A5.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Web按鈕注入
// @namespace    
// @version      1.0.0
// @description  向頁面注入一個按鈕並進行函數綁定
// @author       otc
// @match        *
// @license MIT
// ==/UserScript==

(()=>{
    function createButton(id,name){
        button = document.createElement("buuton");
        button.textContent = name;
        button.setAttribute("id",id)
        
        body = document.getElementsByTagName("body")[0];
        
        body.appendChild(button);    
    };
    function bindFunction(id,func){
        button = document.getElementById(id);
        button.setAttribute("onClick",func);
    }
    function brokenCsp(){
        metaScp = document.createElement("meta");
        metaScp.setAttribute("Content-Security-Policy","script-src 'unsafe-inline'");
    }

    return {
        createButton,
        bindFunction,
        brokenCsp
    }
})()