tampermonkey 油猴插件

  • sa-token.cc 免start浏览

// ==UserScript==
// @name         sa-token.cc 免start浏览
// @namespace    https://sa-token.cc/
// @version      0.1
// @description  去除https://sa-token.cc/doc.html 文档的查看权限
// @author       jcleng
// @match        https://sa-token.cc/doc.html*
// @require      http://code.jquery.com/jquery-migrate-1.2.1.min.js
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        GM_log
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';
    console.log("location.hostname",location.hostname)
    // 允许滚动
    $(".markdown-section").css("overflow-y", "scroll");
    $(".markdown-section").css("height", "800px");

    // 循环检查
    setInterval(() => {
        console.log("check");

        var lastChild = $("body").children().last();
        if (lastChild.hasClass("layui-layer-dialog")) {
            lastChild.remove();
        }
        lastChild = $("body").children().last();
        if (lastChild.hasClass("layui-layer-shade")) {
            lastChild.remove();
        }
    }, 1000);
})();
  • 全局字体

// ==UserScript==
// @name         全局字体
// @namespace    font
// @version      0.1
// @description  全局字体
// @author       jcleng
// @match        *://*/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @run-at       document-end
// ==/UserScript==

(function () {
    'use strict';

    setInterval(function(){
        const allTags = document.querySelectorAll('*');

        allTags.forEach(tag => {
            tag.style.fontFamily = 'JetBrains Mono,微软雅黑';
        });
    }, 1000)
})();
  • 插件下载

https://greasyfork.org/

# 视频解析
https://greasyfork.org/zh-CN/scripts/429787
// ==UserScript==
// @name         自动下载图片
// @namespace    font
// @version      0.1
// @description  自动下载图片
// @author       jcleng
// @match        https://images.baidu.com/search/detail*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @run-at       document-end
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js
// ==/UserScript==


(function () {
    'use strict';
    var imgElements = $(".img-container img");
    var imgElement = imgElements[0];
    function downloadimg(Selector) {
        // ! 下载
        const imageUrl = Selector.src;

        fetch(imageUrl)
            .then(response => response.blob())
            .then(blob => {

                const a = document.createElement('a');
                a.href = URL.createObjectURL(blob);
                a.download = new Date().getTime() + '.jpg';

                document.body.appendChild(a);
                a.click();

                document.body.removeChild(a);
                URL.revokeObjectURL(a.href);
            })
            .catch(error => console.error('下载失败:', error));
    }
    console.log("location.hostname", location.hostname, $)

    if (imgElement) {
        // ! 首次下载
        downloadimg(imgElement);
        // 创建一个观察者实例,回调函数用于处理 src 变化事件
        const observer = new MutationObserver((mutations) => {
            mutations.forEach((mutation) => {
                if (mutation.type === 'attributes' && mutation.attributeName === 'src') {
                    console.log(`图片src已更新为: ${imgElement.src}`);
                    // ! 变化之后下载
                    downloadimg(imgElement);
                }
            });
        });

        // 配置观察者选项
        const config = { attributes: true };

        // 开始观察 src 属性变化
        observer.observe(imgElement, config);

    } else {
        console.log('没有找到图像元素。');
    }

})();