Created
May 22, 2024 21:54
-
-
Save kolibril13/faff17b6d49a114472d3f8f0b6476541 to your computer and use it in GitHub Desktop.
Script to bring back the twitter bird
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Log Hi on X | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Logs Hi to the console on x.com/home, changes the website title, hides a specific element, and changes the favicon. Generated by ChatGPT, no warrenty. | |
// @author Your Name | |
// @match https://x.com/home | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const svgDataUrl = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbDpzcGFjZT0icHJlc2VydmUiIHZpZXdCb3g9IjAgMCAyNDggMjA0Ij4KICA8cGF0aCBmaWxsPSIjMWQ5YmYwIiBkPSJNMjIxLjk1IDUxLjI5Yy4xNSAyLjE3LjE1IDQuMzQuMTUgNi41MyAwIDY2LjczLTUwLjggMTQzLjY5LTE0My42OSAxNDMuNjl2LS4wNGMtMjcuNDQuMDQtNTQuMzEtNy44Mi03Ny40MS0yMi42NCAzLjk5LjQ4IDggLjcyIDEyLjAyLjczIDIyLjc0LjAyIDQ0LjgzLTcuNjEgNjIuNzItMjEuNjYtMjEuNjEtLjQxLTQwLjU2LTE0LjUtNDcuMTgtMzUuMDcgNy41NyAxLjQ2IDE1LjM3IDEuMTYgMjIuOC0uODctMjMuNTYtNC43Ni00MC41MS0yNS40Ni00MC41MS00OS41di0uNjRjNy4wMiAzLjkxIDE0Ljg4IDYuMDggMjIuOTIgNi4zMkMxMS41OCA2My4zMSA0Ljc0IDMzLjc5IDE4LjE0IDEwLjcxYzI1LjY0IDMxLjU1IDYzLjQ3IDUwLjczIDEwNC4wOCA1Mi43Ni00LjA3LTE3LjU0IDEuNDktMzUuOTIgMTQuNjEtNDguMjUgMjAuMzQtMTkuMTIgNTIuMzMtMTguMTQgNzEuNDUgMi4xOSAxMS4zMS0yLjIzIDIyLjE1LTYuMzggMzIuMDctMTIuMjYtMy43NyAxMS42OS0xMS42NiAyMS42Mi0yMi4yIDI3LjkzIDEwLjAxLTEuMTggMTkuNzktMy44NiAyOS07Ljk1LTYuNzggMTAuMTYtMTUuMzIgMTkuMDEtMjUuMiAyNi4xNnoiLz4KPC9zdmc+'; | |
// Function to change the title | |
function changeTitle() { | |
console.log("Hi"); // Print Hi to the console | |
// Change the website title to "Twitter" | |
document.title = "Twitter"; | |
// Change the website title to "Twitter" after 1 second | |
setTimeout(() => { | |
document.title = "Twitter"; | |
console.log("Title changed to Twitter"); | |
}, 500); // Delay of 1 second | |
} | |
// Function to hide the element | |
function hideElement() { | |
var element = document.querySelector('div[aria-label="2 unread items"]'); | |
if (element) { | |
element.style.display = 'none'; | |
console.log("Element hidden:", element); | |
} else { | |
console.log("Element not found"); | |
} | |
} | |
// Function to change the favicon | |
function changeFavicon() { | |
var link = document.querySelector("link[rel~='icon']"); | |
if (!link) { | |
link = document.createElement('link'); | |
link.rel = 'icon'; | |
document.getElementsByTagName('head')[0].appendChild(link); | |
} | |
link.href = svgDataUrl; | |
console.log("Favicon changed"); | |
} | |
// Function to replace the SVG element | |
function replaceSvg() { | |
var svgElement = document.querySelector('svg[aria-hidden="true"].r-4qtqp9'); | |
if (svgElement) { | |
var newSvg = document.createElement('img'); | |
newSvg.src = svgDataUrl; | |
newSvg.width = svgElement.width.baseVal.value; | |
newSvg.height = svgElement.height.baseVal.value; | |
svgElement.parentNode.replaceChild(newSvg, svgElement); | |
console.log("SVG element replaced"); | |
} else { | |
console.log("SVG element not found"); | |
} | |
} | |
// Function to call hideElement 10 times at intervals of 0.1 seconds | |
function callHideElementMultipleTimes() { | |
for (let i = 1; i <= 10; i++) { | |
setTimeout(hideElement, i * 100); | |
} | |
} | |
// Run the functions when the page loads | |
window.addEventListener('load', () => { | |
setTimeout(() => { | |
changeTitle(); | |
callHideElementMultipleTimes(); | |
changeFavicon(); | |
replaceSvg(); | |
}, 500); // Delay of 0.5 second | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment