Skip to content

Commit 435900e

Browse files
committed
chore: release 1.4.1
1 parent 4bac052 commit 435900e

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

dist/twitter.user.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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
@@ -230,18 +230,33 @@
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

packages/userscript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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 𝕏.",

0 commit comments

Comments
 (0)