* initial commit

meow
Dominika 2022-01-26 17:41:55 +01:00
commit ce4cf78dec
3 changed files with 42 additions and 0 deletions

22
content_script.js Normal file
View File

@ -0,0 +1,22 @@
function getUrl(e) {
var target = e.target;
console.log(e);
while ((target.tagName != "A" || !target.href) && target.parentNode) {
target = target.parentNode;
}
if (target.tagName != "A") return;
if (target.href.startsWith("https://t.co")) {
let url = '';
e.preventDefault();
console.log(e.target.children);
url = e.target.textContent.replace("…","")
if(url.startsWith("http")) {
window.open(url, '_blank');
} else {
window.open(target.href, '_blank'); // opengraph cards don't contain the original URLs
}
}
}
window.addEventListener("click", getUrl);

BIN
icons/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

20
manifest.json Normal file
View File

@ -0,0 +1,20 @@
{
"manifest_version": 2,
"name": "Twitter t.co remover",
"description": "recovers original URLs where possible",
"version": "1.0",
"icons": {
"64": "icons/icon.png"
},
"content_scripts": [
{
"matches": [
"*://*.twitter.com/*",
"*://twitter.com/*"
],
"js": [
"content_script.js"
]
}
]
}