Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let ids = [];
- setInterval(() => {
- const shareButtons = document.querySelectorAll('[aria-label="Share\ Tweet"]');
- if (!shareButtons) {
- console.log("Couldn't find share buttons");
- return;
- }
- for (const shareButton of shareButtons) {
- const id = shareButton.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.attributes.getNamedItem("aria-labelledby")?.value;
- if (id && ids.includes(id)) return;
- ids.push(id)
- shareButton.addEventListener("click", (event) => {
- setTimeout(() => {
- const targetButton = document.querySelector('[data-testid="Dropdown"] > :first-child');
- targetButton.addEventListener('click', () => {
- // Function to run when the button is pressedc
- setTimeout(myFunction, 300)
- });
- async function myFunction() {
- const permission = await navigator.permissions.query({
- name: "clipboard-read",
- });
- if (permission.state === "denied") {
- throw new Error("Not allowed to read clipboard.");
- }
- const clipboardContents = await navigator.clipboard.readText();
- await navigator.clipboard.writeText(clipboardContents.replace("twitter.com", "twitter-og.com"))
- console.log("Wrote " + clipboardContents.replace("twitter.com", "twitter-og.com"))
- }
- }, 500)
- })
- }
- }, 1000)
Advertisement
Add Comment
Please, Sign In to add comment