您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
增进 Greasyfork 浏览体验。
当前为
// ==UserScript== // @name Greasy Fork镜像 Enhance // @name:zh-CN Greasy Fork镜像 增强 // @namespace http://tampermonkey.net/ // @version 0.1.2 // @description Enhance your experience at Greasyfork. // @description:zh-CN 增进 Greasyfork 浏览体验。 // @author PRO // @match https://greasyfork.dpdns.org/* // @icon https://greasyfork.dpdns.org/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.replaceAll(" ", "-"); s = s.replaceAll("%20", "-"); // Remove emojis (such a headache) s = s.replaceAll(/([\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 })();