Created
January 15, 2024 10:54
-
-
Save blackout314/c1b5386914968dec776964468f937d45 to your computer and use it in GitHub Desktop.
altcoinstalks.com archiveis/shorturl utility v1.0
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 archive-is_altcoinstalks | |
// @namespace https://www.altcoinstalks.com/ | |
// @description multi-utility v 1.0 | |
// @include https://www.altcoinstalks.com/* | |
// @require https://code.jquery.com/jquery-2.2.4.min.js | |
// @grant window.focus | |
// ==/UserScript== | |
var links,thisLink; | |
const replace = 'https://'; | |
const replaced = 'https://archive.is/?run=1&url=https://'; | |
let loc; | |
var openAndClose = function(elem) { | |
var url = elem.originalTarget.dataset.www; | |
let newWindow = window.open(url, '_blank' /*, 'width=300,height=300'*/); | |
window.focus(); | |
console.log('URL', url); | |
setTimeout(function(){ | |
loc = newWindow.location; | |
console.log('ARCHIVE', loc); | |
elem.originalTarget.innerText = 'β '; | |
//newWindow.close(); | |
}, 2000); | |
} | |
function createPageLink() { | |
var archivethis = window.location.href; | |
var newHTML = document.createElement ('div'); | |
newHTML.innerHTML = ' <style>.g{background:green; color:white;} .o{background:orange;}</style><span id="toolbar-dash"> <span><a data-ref="current" title="archive-is" target="_blank" href="https://archive.is/?run=1&url='+archivethis+'">ARCHIVE π¦</a></span> '+ | |
' <span><a data-ref="current" title="short-is" target="_blank" href="https://tinyurl.com/create.php?url='+archivethis+'">SHORT π</a></span>'+ | |
' <span id="extraspace">.</span> <span id="extracount"></span> </span> <span id="toolbar-close">βοΈ</span> '; | |
newHTML.style = 'position:fixed;top:0;left:0px;border:1px black solid;background:white;font-size:8px;'; | |
document.body.appendChild(newHTML); | |
} | |
function createArchiveLink(archivethis, thisLink, dataattrib) { | |
var newHTML = document.createElement ('span'); | |
newHTML.innerHTML = '</a> ['+ | |
'<a target="_blank" href="https://tinyurl.com/create.php?url='+thisLink+'">π</a> '+ | |
'<a data-ref="'+dataattrib+'" title="archive-is" target="_blank" href="'+archivethis+'">π¦</a>'+ | |
']'; | |
thisLink.parentNode.insertBefore(newHTML, thisLink.nextSibling); | |
} | |
function addGlobalStyle(css) { | |
var head, style; | |
head = document.getElementsByTagName('head')[0]; | |
if (!head) { return; } | |
style = document.createElement('style'); | |
style.type = 'text/css'; | |
style.innerHTML = css; | |
head.appendChild(style); | |
} | |
function isForumLink(thisLink) { | |
return thisLink.href.indexOf('altcoinstalks') > 0; | |
} | |
links = document.evaluate("//td[@class='subject windowbg2']/div/span/a", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
for (var i=0;i<links.snapshotLength;i++) { | |
var thisLink = links.snapshotItem(i); | |
if(isForumLink(thisLink)) { | |
var archivethis = thisLink.href.replace(replace, replaced); | |
console.log(thisLink); | |
createArchiveLink(archivethis, thisLink, 'one'); | |
} | |
} | |
links = document.evaluate("//div[@class='subject']/a[@href]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
for (var i=0;i<links.snapshotLength;i++) { | |
var thisLink = links.snapshotItem(i); | |
if(isForumLink(thisLink)) { | |
var archivethis = thisLink.href.replace(replace, replaced); | |
console.log(thisLink); | |
createArchiveLink(archivethis, thisLink, 'two'); | |
} | |
} | |
links = document.evaluate("//a[text()='All']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
for (var i=0;i<links.snapshotLength;i++) { | |
var thisLink = links.snapshotItem(i); | |
if(isForumLink(thisLink)) { | |
var archivethis = thisLink.href.replace(replace, replaced); | |
console.log(thisLink); | |
createArchiveLink(archivethis, thisLink, 'three'); | |
} | |
} | |
document.querySelectorAll('.new').forEach((elem) => { | |
elem.addEventListener('click', openAndClose, false); | |
}); | |
createPageLink(); | |
var closed_flag = false; | |
$('#toolbar-close').off('click'); | |
$('#toolbar-close').on('click', function(e){ | |
if(closed_flag) { | |
$('#toolbar-dash').css('display','initial'); | |
closed_flag = false; | |
} else { | |
$('#toolbar-dash').css('display','none'); | |
closed_flag = true; | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment