Last active
August 3, 2020 18:56
-
-
Save pacochi/d1a8e019fdfc02235df7686af62d9895 to your computer and use it in GitHub Desktop.
Mastodon の静的ページで絵文字を動かします。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name [Mastodon] animate emoji on static pages | |
// @namespace hen.acho.co | |
// @include /^https?:\/\/[^\/]+\/(?:@\w+|users\/\w+\/(?:statuses|updates))\/\d+/ | |
// @version 1.200804 | |
// @description We can 👀 animated emoji without logging in! | |
// @downloadURL https://gist.github.com/pacochi/d1a8e019fdfc02235df7686af62d9895/raw/mastodon_animate_emoji.user.js | |
// @run-at document-idle | |
// @grant none | |
// ==/UserScript== | |
{ | |
document.querySelectorAll('img.emojione[alt^=":"]').forEach(cemoji => { | |
if (cemoji.dataset.static) return(cemoji.src = cemoji.dataset.static = cemoji.dataset.original); | |
const orig = cemoji.src; | |
cemoji.addEventListener('error', e => e.target.src = orig, { once: true }); | |
cemoji.src = cemoji.src.replace(/\/static(\/.+\.png)/, '/original$1'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment