// ==UserScript== // @name No GIF Avatars // @name:zh-CN 屏蔽 GIF 头像 // @namespace https://www.pipecraft.net/ // @homepageURL https://github.com/utags/utags#readme // @supportURL https://github.com/utags/utags/issues // @version 0.0.1 // @description Convert GIF avatars into static images // @description:zh-CN 将动图头像转换为静态图片。 // @author Pipecraft // @license MIT // @match https://linux.do/* // @match https://www.nodeloc.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com // @grant GM_addStyle // @downloadURL https://update.greasyfork.icu/scripts/529447/No%20GIF%20Avatars.user.js // @updateURL https://update.greasyfork.icu/scripts/529447/No%20GIF%20Avatars.meta.js // ==/UserScript== ;(function () { "use strict" const style = ` .PostUser-name .username { text-shadow: unset !important; animation: unset !important; } .fa-beat { animation-name: unset !important; } .UserBadge { animation: unset !important; } .decorationAvatarFrameImageSource { display: none; } ` GM_addStyle(style) function shouldUpdateWhenNodeUpdated(nodeList) { for (const node of nodeList) { if (node.nodeName === "IMG") { return true } } return false } function replaceImgSrc() { document.querySelectorAll("img").forEach((element) => { element.src = element.src.replace(".gif", ".png") }) } const observer = new MutationObserver(async (mutationsList) => { let shouldUpdate = false for (const mutationRecord of mutationsList) { if (1 || shouldUpdateWhenNodeUpdated(mutationRecord.addedNodes)) { shouldUpdate = true break } } if (shouldUpdate) { setTimeout(replaceImgSrc, 10) } }) observer.observe(document, { childList: true, subtree: true, }) replaceImgSrc() })()