Created
March 16, 2025 06:43
-
-
Save siutin/b9621796f05ad3e95a95010b6ec8e2df to your computer and use it in GitHub Desktop.
Tampermoneky script to fix x t.co link
This file contains hidden or 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 fix x link | |
// @namespace https://github.com/siutin/ | |
// @version 1.0.0 | |
// @description replace t.co with the original link! | |
// @author siutin | |
// @match https://x.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=x.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function fix () { | |
console.log('fix x start') | |
const aList = Array.from(document.querySelectorAll('a').values()).filter(o => o.href && o.href.startsWith('https://t.co/')) | |
aList.forEach(a => { | |
console.log(`before link: ${a.href}`) | |
const spans = a.querySelectorAll('span') | |
spans.forEach(span => span.parentNode.replaceChild(document.createTextNode(span.textContent), span)) | |
a.href = `${a.innerText}`.replace(/…/g, '') | |
console.log(`after link: ${a.href}`) | |
}) | |
console.log('fix x end') | |
} | |
setTimeout(() => { | |
const div = document.createElement('div') | |
div.setAttribute("id", "magic-box") | |
div.style.cssText = 'position: fixed; top: 0; right: 0; z-index: 1000; min-width: 20px; min-height: 20px; background: #ffffff; border: 1px solid #cccccc;' | |
const fixBtn = document.createElement('button') | |
fixBtn.textContent = 'Fix' | |
fixBtn.style.cssText = 'font-family: monospace; font-weight: bold; margin: 2pt;' | |
fixBtn.onclick = fix | |
div.appendChild(fixBtn) | |
document.querySelector('main').appendChild(div) | |
}, 2000) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment