Last active
December 31, 2018 17:46
-
-
Save stripedpurple/6d1c6f58fd7223e8bd141b302f0a9211 to your computer and use it in GitHub Desktop.
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 Snahp Link Copier | |
// @namespace http://stripedpurple.io | |
// @version 2018.12.30.2 | |
// @description adds copy button to Snahp link list | |
// @author Austin Barrett | |
// @match *://links.snahp.it/* | |
// @grant none | |
// ==/UserScript== | |
window.onload = function () { | |
'use strict'; | |
var textArea = document.createElement("textArea"); | |
var copyBtn = document.createElement("button"); | |
textArea.style.width = '0px' | |
textArea.style.height = '0px' | |
textArea.style.position = 'absolute' | |
textArea.style.top = '-10px' | |
textArea.style.right = '-10px' | |
copyBtn.onclick = function () { | |
copy(textArea) | |
}; | |
copyBtn.innerText = "Copy Links!"; | |
document.querySelectorAll('p[align="center"]')[0].parentNode.appendChild(copyBtn); | |
document.body.appendChild(textArea); | |
document.querySelectorAll('center p a').forEach(function (a) { | |
textArea.value += a.href + '\n' | |
}); | |
} | |
function copy(elem) { | |
elem.select(); | |
document.execCommand('copy'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment