Greasy Fork is available in English.
Get our Twitter back from Elon.
当前为
// ==UserScript==
// @name X to Twitter
// @name:ja X to Twitter
// @description Get our Twitter back from Elon.
// @namespace https://xtotwitter.yakisova.com
// @version 1.7.0
// @author yakisova41
// @match https://twitter.com/*
// @match https://X.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant unsafeWindow
// @run-at document-start
// @license MIT
// @description:ja イーロンから私達のTwitterを取り戻します
// ==/UserScript==
'use strict';
const xLogoPath = "M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"
const loadingXLogoPath = "M14.258 10.152L23.176 0h-2.113l-7.747 8.813L7.133 0H0l9.352 13.328L0 23.973h2.113l8.176-9.309 6.531 9.309h7.133zm-2.895 3.293l-.949-1.328L2.875 1.56h3.246l6.086 8.523.945 1.328 7.91 11.078h-3.246zm0 0"
const birdPath = "M23.643 4.937c-.835.37-1.732.62-2.675.733.962-.576 1.7-1.49 2.048-2.578-.9.534-1.897.922-2.958 1.13-.85-.904-2.06-1.47-3.4-1.47-2.572 0-4.658 2.086-4.658 4.66 0 .364.042.718.12 1.06-3.873-.195-7.304-2.05-9.602-4.868-.4.69-.63 1.49-.63 2.342 0 1.616.823 3.043 2.072 3.878-.764-.025-1.482-.234-2.11-.583v.06c0 2.257 1.605 4.14 3.737 4.568-.392.106-.803.162-1.227.162-.3 0-.593-.028-.877-.082.593 1.85 2.313 3.198 4.352 3.234-1.595 1.25-3.604 1.995-5.786 1.995-.376 0-.747-.022-1.112-.065 2.062 1.323 4.51 2.093 7.14 2.093 8.57 0 13.255-7.098 13.255-13.254 0-.2-.005-.402-.014-.602.91-.658 1.7-1.477 2.323-2.41z";
const twitterColor = "rgb(29, 155, 240)";
const loadingBirdColor = "rgba(29,161,242,1.00)";
const style = document.createElement("style");
let head;
if(GM_info.scriptHandler === "Userscripts") {
head = document.head;
trashSafari();
style.innerHTML = `
.x-to-twitter {
fill: inherit;
color: ${twitterColor};
}
div[style="color: rgb(239, 243, 244);"] > svg > g > path {
color: rgb(239, 243, 244);
}
div[aria-label="Loading…"] > svg > g > path {
fill: inherit;
color: ${loadingBirdColor};
}
`;
}
else {
head = unsafeWindow.document.head;
style.innerHTML = `
path[d="${xLogoPath}"], path[d="${loadingXLogoPath}"] {
d:path("${birdPath}");
fill: inherit;
color: ${twitterColor};
}
div[style="color: rgb(239, 243, 244);"] > svg > g > path {
color: rgb(239, 243, 244);
}
div[aria-label="Loading…"] > svg > g > path {
d:path("${birdPath}");
fill: inherit;
color: ${loadingBirdColor};
}
`;
}
if(head !== null && head !== undefined){
headFound(head);
}
else {
const i = setInterval(()=>{
if(document.head !== undefined && document.head !== null) {
headFound(document.head)
clearInterval(i);
}
}, 100);
}
function headFound(head) {
const shortcutIcon = head.querySelector('[rel="shortcut icon"]')
if(shortcutIcon !== null) {
shortcutIcon.href = "data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJkSURBVHgB7VZBbtpQEH3zIW0WVYuXVaH4Bs0NSk4AOUFhEarskhMknIDsqkKlcIT0BNAT1D1B3ZJK3dmVuirwp/MhVmzAxiagKBJv9+ePZ97M/JkxsMMODwzChlD84FWQp3MxeCDHAhiumB+MJrr1+8Ryw3p/9+H4DctfIPCq49Xlw8Kv99YlMuB19885gy/i7llziwGfFFWJyR02XzSCuwiBUse7BlFVaz5LS8KQVkRXaXRJsqImfDjKSZBNyzEyFWFKVJ4KFbWLElUao6KbSk8i9TXgTPaorxTskPwOxa7/9baGt4zg8oQbNyfWYJlRU0/KUx9ZwNwYNq1ecFRzl18QpW0bB0Ks//KjV1uwlbuLJA3GxEdh5wb5yGEPl3qMd2xecYQHKnlFlVLX95kxYCFKGg5IlU2a0uLpCM68LEJA+sJ/Dm6Jy3aMjQIRakRUm+UuvfOp/X34iQSejeFo0Hdx4optG5uFH/R+GHNvANcm3VtwLs+Lvy2TRwhIOnrYHhysIuDKcCDwGbYAjglOzQt+HssElF6dvoNNOZeuCSbfSgIGMjILMo4/ExZf7TqghNLmlwm1gpSC2tmaLAZMvWGz0Iu7XpqBm2NrQNN5cD+Y5ZOTdZyok3RZMusZOJUN+QZrQFb0oQkG6xIIYHe8A03Unx/Ryd6jS2ctAsbxmFRVynGKlM5na5ePVkUe0p+h9MmraS2zXqYgmSWjOPtElHbLTVB3Q79gqQlMScxqXpeav0UWiGMmXKSNOpZAAPvKs/U/1MRoxRxl+5WD+psUy2D5IdmRVoWjnqDnLlkyO+zwaPAf1zXwZL751PUAAAAASUVORK5CYII=";
}
head.appendChild(style);
titleChange(head);
}
function titleChange(head) {
const i = setInterval(()=>{
const titleEl = head.querySelector("title");
if(titleEl !== null) {
const titleOb = new MutationObserver(()=>{
if(titleEl.innerHTML === "X") {
titleEl.innerHTML = "Twitter";
}
else {
const split = titleEl.innerHTML.split("/");
if(split[1] === " X"){
split[1] = " Twitter";
titleEl.innerHTML = split.join("/");
}
}
});
titleOb.observe(titleEl, {
childList: true
});
clearInterval(i);
}
},100);
}
function trashSafari() {
setInterval(()=>{
const pathElems = document.querySelectorAll(`path[d="${xLogoPath}"]:not(.x-to-twitter), path[d="${loadingXLogoPath}"]:not(.x-to-twitter)`);
if(pathElems.length !== 0) {
pathElems.forEach(path => {
path.setAttribute("d", birdPath);
path.classList.add("x-to-twitter");
});
}
},100);
document.querySelector('div[aria-label="Loading…"] > svg > g > path').setAttribute("d", birdPath);
}