From 435900edb23f7a927f205fdf6525a511a6d09e00 Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Fri, 28 Jul 2023 21:09:36 +0800 Subject: [PATCH] chore: release 1.4.1 --- dist/twitter.user.js | 27 +++++++++++++++++++++------ packages/userscript/package.json | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/dist/twitter.user.js b/dist/twitter.user.js index 40c68bb..b46162e 100644 --- a/dist/twitter.user.js +++ b/dist/twitter.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Get Twitter Icons Back // @namespace Pionxzh -// @version 1.4.0 +// @version 1.4.1 // @author Pionxzh // @description Brings back the blue bird icon on Twitter. No more 𝕏. // @license MIT @@ -230,10 +230,25 @@ } }); } - function replaceTitle() { - const title = document.querySelector("title"); - if (!title) - return; + async function waitForTitle() { + return new Promise((resolve) => { + const title = document.querySelector("title"); + if (title) { + resolve(title); + } else { + const observer = new MutationObserver(() => { + const title2 = document.querySelector("title"); + if (title2) { + observer.disconnect(); + resolve(title2); + } + }); + observer.observe(document.head, { childList: true }); + } + }); + } + async function replaceTitle() { + const el = await waitForTitle(); const sync = () => { if (document.title.endsWith(" / X")) { document.title = `${document.title.slice(0, -1)}Twitter`; @@ -241,7 +256,7 @@ }; sync(); window.addEventListener("visibilitychange", sync); - new MutationObserver(sync).observe(title, mutationObserverOptions); + new MutationObserver(sync).observe(el, mutationObserverOptions); } main(); diff --git a/packages/userscript/package.json b/packages/userscript/package.json index b168713..6e82efd 100644 --- a/packages/userscript/package.json +++ b/packages/userscript/package.json @@ -1,7 +1,7 @@ { "name": "@pionxzh/twitter-icon-userscript", "type": "module", - "version": "1.4.0", + "version": "1.4.1", "private": true, "title": "Get Twitter Icons Back", "description": "Brings back the blue bird icon on Twitter. No more 𝕏.",