Skip to content

Instantly share code, notes, and snippets.

@Bo-Duke
Last active August 30, 2018 14:56
Show Gist options
  • Select an option

  • Save Bo-Duke/34dc8156de4123503f98f01a2c35d69a to your computer and use it in GitHub Desktop.

Select an option

Save Bo-Duke/34dc8156de4123503f98f01a2c35d69a to your computer and use it in GitHub Desktop.
Open all Jenkins screenshots in Firefox
// ==UserScript==
// @name Copy Jenkins
// @version 1
// @grant none
// ==/UserScript==
// https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f
const copyToClipboard = str => {
const el = document.createElement('textarea'); // Create a <textarea> element
el.value = str; // Set its value to the string that you want copied
el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof
el.style.position = 'absolute';
el.style.left = '-9999px'; // Move outside the screen to make it invisible
document.body.appendChild(el); // Append the <textarea> element to the HTML document
el.select(); // Select the <textarea> content
document.execCommand('copy'); // Copy - only works as a result of a user action (e.g. click events)
document.body.removeChild(el); // Remove the <textarea> element
};
const getLinks = () => Array.from(document.querySelector('#ygtvc23').querySelectorAll('a:not(.ygtvspacer)')).reduce((acc, cur) => acc + cur + " ", "")
setTimeout(() => {
const desc = document.querySelector('#description>div[align="right"]');
const a = document.querySelector('#description-link');
const button = document.createElement('a');
button.innerText = "Copy links ";
button.href = "#";
button.onclick = e => copyToClipboard(getLinks());
desc.insertBefore(button, a);
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment