您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
替换丧尸头像,屏蔽图片,公共场合也能上北+
当前为
// ==UserScript== // @name North-Plus SFW // @namespace https://github.com/sssssssl/NP-scripts // @version 0.1 // @description 替换丧尸头像,屏蔽图片,公共场合也能上北+ // @author sl // @match https://*.white-plus.net/read.php?tid* // @match https://*.south-plus.net/read.php?tid* // @match https://*.imoutolove.me/read.php?tid* // @grant none // ==/UserScript== (function () { 'use strict'; // 1. CONSTANTS. const TIME_FADE_IN = 5; const TIME_FADE_OUT = 0.5; const CLS_AVATAR = 'img.pic'; const BASE_URL = 'images/face'; const SAFE_AVATARS = [ 'a3.gif', '7.gif', 'a10.gif', 'a14.gif', 'a8.gif', '4.gif', '0.gif', '3.gif', 'a12.gif', 'none.gif', 'a4.gif', '5.gif', 'a11.gif', '8.gif', 'a6.gif', '2.gif', 'a15.gif', '9.png', 'a7.gif', 'a9.gif', 'a16.gif', '6.gif', 'a5.gif', 'a13.gif', 'a2.gif', ]; const N = SAFE_AVATARS.length; const CLS_IMG = '.f14 img'; const CLS_IMG_BLOCKER = 'img-blocker'; const CLS_BLOCKER_ENABLED = 'blocker-enabled'; const BLOCKER_STYLE = ` div.${CLS_BLOCKER_ENABLED} { position:absolute; background-color:#F2F3F4; opacity: 1; transition: opacity ${TIME_FADE_OUT}s; } div.${CLS_BLOCKER_ENABLED}:hover { opacity: 0; transition: opacity ${TIME_FADE_IN}s; }`; // 2. CODE ENTRYPOINT. let imgs = Array.from(document.querySelectorAll(CLS_IMG)).filter( (im) => { return (!im.src.includes('images/post')); }); if (imgs) { let blockerStyleTag = document.createElement('style'); blockerStyleTag.textContent = BLOCKER_STYLE; document.head.append(blockerStyleTag); imgs.forEach((im) => { imgBlockerCb(im); }); } // 设置头像 let avatars = Array.from(document.querySelectorAll(CLS_AVATAR)); avatars.forEach((im) => { im.src = getRandomAvatar(); im.style.width = `150px`; im.style.height = `150px`; }); function imgBlockerCb(im) { let blocker = document.createElement('div'); blocker.classList.add(CLS_IMG_BLOCKER); blocker.classList.add(CLS_BLOCKER_ENABLED); blocker.style.height = `${im.height}px`; blocker.style.width = `${im.width}px`; let wrapper = document.createElement('div'); im.parentElement.insertBefore(wrapper, im); wrapper.append(blocker, im); } function getRandomAvatar() { let index = Math.floor(Math.random() * N); return `${BASE_URL}/${SAFE_AVATARS[index]}`; } })();