File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed
Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change 11// ==UserScript==
22// @name Get Twitter Icons Back
33// @namespace Pionxzh
4- // @version 1.4.0
4+ // @version 1.4.1
55// @author Pionxzh
66// @description Brings back the blue bird icon on Twitter. No more 𝕏.
77// @license MIT
230230 }
231231 } ) ;
232232 }
233- function replaceTitle ( ) {
234- const title = document . querySelector ( "title" ) ;
235- if ( ! title )
236- return ;
233+ async function waitForTitle ( ) {
234+ return new Promise ( ( resolve ) => {
235+ const title = document . querySelector ( "title" ) ;
236+ if ( title ) {
237+ resolve ( title ) ;
238+ } else {
239+ const observer = new MutationObserver ( ( ) => {
240+ const title2 = document . querySelector ( "title" ) ;
241+ if ( title2 ) {
242+ observer . disconnect ( ) ;
243+ resolve ( title2 ) ;
244+ }
245+ } ) ;
246+ observer . observe ( document . head , { childList : true } ) ;
247+ }
248+ } ) ;
249+ }
250+ async function replaceTitle ( ) {
251+ const el = await waitForTitle ( ) ;
237252 const sync = ( ) => {
238253 if ( document . title . endsWith ( " / X" ) ) {
239254 document . title = `${ document . title . slice ( 0 , - 1 ) } Twitter` ;
240255 }
241256 } ;
242257 sync ( ) ;
243258 window . addEventListener ( "visibilitychange" , sync ) ;
244- new MutationObserver ( sync ) . observe ( title , mutationObserverOptions ) ;
259+ new MutationObserver ( sync ) . observe ( el , mutationObserverOptions ) ;
245260 }
246261 main ( ) ;
247262
Original file line number Diff line number Diff line change 11{
22 "name" : " @pionxzh/twitter-icon-userscript" ,
33 "type" : " module" ,
4- "version" : " 1.4.0 " ,
4+ "version" : " 1.4.1 " ,
55 "private" : true ,
66 "title" : " Get Twitter Icons Back" ,
77 "description" : " Brings back the blue bird icon on Twitter. No more 𝕏." ,
You can’t perform that action at this time.
0 commit comments