Website Customizer

Customize website font size, background color, and text color

当前为 2023-04-22 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Website Customizer
// @namespace    http://tampermonkey.net/
// @version      1
// @description  Customize website font size, background color, and text color
// @author       Wrldz
// @license      MIT
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Create a div element to hold the customization controls
    var customizerDiv = document.createElement("div");
    customizerDiv.style.position = "fixed";
    customizerDiv.style.bottom = "20px";
    customizerDiv.style.right = "20px";
    customizerDiv.style.padding = "10px";
    customizerDiv.style.backgroundColor = "white";
    customizerDiv.style.borderRadius = "10px";
    customizerDiv.style.boxShadow = "0px 0px 10px rgba(0,0,0,0.5)";

    // Create a font size control
    var fontSizeLabel = document.createElement("label");
    fontSizeLabel.textContent = "Font Size: ";
    var fontSizeInput = document.createElement("input");
    fontSizeInput.type = "range";
    fontSizeInput.min = "12";
    fontSizeInput.max = "24";
    fontSizeInput.value = "16";
    fontSizeInput.style.marginLeft = "5px";
    fontSizeInput.style.verticalAlign = "middle";
    fontSizeInput.addEventListener("input", function() {
        document.body.style.fontSize = fontSizeInput.value + "px";
    });
    fontSizeLabel.appendChild(fontSizeInput);
    customizerDiv.appendChild(fontSizeLabel);

    // Create a background color control
    var bgColorLabel = document.createElement("label");
    bgColorLabel.textContent = "Background Color: ";
    var bgColorInput = document.createElement("input");
    bgColorInput.type = "color";
    bgColorInput.value = "#ffffff";
    bgColorInput.style.marginLeft = "5px";
    bgColorInput.style.verticalAlign = "middle";
    bgColorInput.addEventListener("input", function() {
        document.body.style.backgroundColor = bgColorInput.value;
    });
    bgColorLabel.appendChild(bgColorInput);
    customizerDiv.appendChild(bgColorLabel);

    // Create a text color control
    var textColorLabel = document.createElement("label");
    textColorLabel.textContent = "Text Color: ";
    var textColorInput = document.createElement("input");
    textColorInput.type = "color";
    textColorInput.value = "#000000";
    textColorInput.style.marginLeft = "5px";
    textColorInput.style.verticalAlign = "middle";
    textColorInput.addEventListener("input", function() {
        document.body.style.color = textColorInput.value;
    });
    textColorLabel.appendChild(textColorInput);
    customizerDiv.appendChild(textColorLabel);

    // Add the customizer div to the document
    document.body.appendChild(customizerDiv);
})();