Greasy Fork镜像 增强

增进 Greasyfork 浏览体验。

目前为 2023-05-25 提交的版本。查看 最新版本

// ==UserScript==
// @name         Greasy Fork镜像 Enhance
// @name:zh-CN   Greasy Fork镜像 增强
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  Enhance your experience at Greasyfork.
// @description:zh-CN 增进 Greasyfork 浏览体验。
// @author       PRO
// @match        https://gf.qytechs.cn/*
// @icon         https://gf.qytechs.cn/vite/assets/blacklogo16-bc64b9f7.png
// @license      gpl-3.0
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    function sanitify(s) {
        // Trim spaces and newlines
        s = s.trim();
        // Replace spaces
        s = s.replace(" ", "-");
        s = s.replace("%20", "-");
        // Remove emojis
        s = s.replace(/([\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2580-\u27BF]|\uD83E[\uDD10-\uDEFF]|\uFE0F| )+-/g, '');
        return s;
    }
    function process(node) { // Add anchor and assign id to given node
        if (node.childElementCount > 1) return; // Ignore complex nodes
        node.id = sanitify(node.textContent); // Assign id
        // Add anchors
        let node_ = document.createElement('a');
        node_.className = 'anchor';
        node_.href = '#' + node.id;
        node.appendChild(node_);
    }
    // Css for anchors
    let css = document.createElement("style");
    css.textContent = `
    html {
        scroll-behavior: smooth;
    }
    a.anchor::before {
        content: "#";
    }
    a.anchor {
        opacity: 0;
        text-decoration: none;
        padding: 0px 0.5em;
        -moz-transition: all 0.25s ease-in-out;
        -o-transition: all 0.25s ease-in-out;
        -webkit-transition: all 0.25s ease-in-out;
        transition: all 0.25s ease-in-out;
    }
    h1:hover>a.anchor,
    h2:hover>a.anchor,
    h3:hover>a.anchor,
    h4:hover>a.anchor,
    h5:hover>a.anchor,
    h6:hover>a.anchor {
        opacity: 1;
        -moz-transition: all 0.25s ease-in-out;
        -o-transition: all 0.25s ease-in-out;
        -webkit-transition: all 0.25s ease-in-out;
        transition: all 0.25s ease-in-out;
    }
    @media (any-hover: none) {
        a.anchor {
            opacity: 1;
        }
    }`;
    document.querySelector("head").appendChild(css); // Inject css
    document.querySelectorAll("body > div.width-constraint h1, h2, h3, h4, h5, h6").forEach(process); // Main
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址