Skip to content

Instantly share code, notes, and snippets.

@stripedpurple
Last active December 31, 2018 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stripedpurple/6d1c6f58fd7223e8bd141b302f0a9211 to your computer and use it in GitHub Desktop.
Save stripedpurple/6d1c6f58fd7223e8bd141b302f0a9211 to your computer and use it in GitHub Desktop.
// ==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