您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Imgur's "old design" sometimes includes """ and "'" in post descriptions instead of quotation marks. This replaces them with the appropriate characters.
当前为
- // ==UserScript==
- // @name Imgur - Fix Quotation Marks in the Old Design
- // @namespace http://tampermonkey.net/
- // @version 1.0.0
- // @description Imgur's "old design" sometimes includes """ and "'" in post descriptions instead of quotation marks. This replaces them with the appropriate characters.
- // @author Corrodias
- // @match https://imgur.com/*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=imgur.com
- // @grant none
- // @license MIT
- // ==/UserScript==
- (function() {
- 'use strict';
- const mutationObserver = new MutationObserver(mutations => {
- for (const mutation of mutations) {
- processMutation(mutation);
- }
- });
- function processMutation(mutation) {
- for (const node of mutation.addedNodes) {
- if (node.nodeType !== Node.ELEMENT_NODE) continue;
- // Only act if a new post has been loaded.
- if (!node.classList.contains('post-image-container')) return;
- replaceText(node);
- }
- }
- function replaceText(post) {
- // This is empty if the current page is not a post.
- const description = post.getElementsByClassName('post-image-description');
- for (const a of description) {
- a.textContent = a.textContent.replaceAll('"', '"').replaceAll(''', "'");
- }
- }
- // Monitor dynamically loaded content, for when the user nagivates to a new post. Observe as little as possible.
- const postContent = document.body.getElementsByClassName('post-images');
- for (const a of postContent) {
- mutationObserver.observe(a, { attributes: false, childList: true, subtree: true });
- }
- // Also run the replacement now in case this is a post.
- replaceText(document.body);
- })();