您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Fixes RES Twitter expandos in Firefox
当前为
// ==UserScript== // @name RES Twitter Fix // @namespace com.res-twitter-fix // @description Fixes RES Twitter expandos in Firefox // @match https://*.reddit.com/* // @run-at document-end // @grant none // @version 3.0 // ==/UserScript== "use strict" function injectTwitterScript() { // inject twitter script to convert blockquotes into pretty twitter displays const script = document.createElement( 'script' ) script.src = 'https://platform.twitter.com/widgets.js' document.body.appendChild( script ) } function fixExpandos() { // look for twitter expandos and proceed if any are found console.log( 'looking for expandos' ) const expandos = document.querySelectorAll( '.twitter-tweet' ) if ( expandos.length > 0 ) { console.log( 'fixing expandos!' ) injectTwitterScript() // hide expando buttons as re-collapsing introduces a great deal of issues // don't worry, only buttons for twitter expandos are hidden! const buttons = document.querySelectorAll( '.expando-button[data-host="twitter"]' ) for ( const btn of buttons ) btn.style.visibility = 'hidden' } } function onClick( e ) { // check if we've clicked an expando button if ( e.target.className.includes( 'expando-button' ) ) { // fix expandos on click fixExpandos() // also attempt to fix auto-expanded expandos... // perhaps this is not the most reliable way to do it, as there's // no way to know exactly how long it'll take RES to auto-expand. // regardless, injecting the script twice does no harm setTimeout( () => { fixExpandos() }, 1000 ) } } document.addEventListener( 'click', onClick, false )