Duclv

random copy

Mar 31st, 2022
1,307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Random add copy
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       duclv
  7. // @match        https://www.bestrandoms.com/random-address-in-us
  8. // @icon         https://www.google.com/s2/favicons?sz=64&domain=bestrandoms.com
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.     'use strict';
  14.     document.querySelector('#main .content').insertAdjacentHTML('beforebegin','<button onclick="copyall()">COPY ALL</button>');
  15.     window.copyToClipboard = function(text) {
  16.         var dummy = document.createElement('textarea');
  17.         document.body.appendChild(dummy);
  18.         dummy.value = text;
  19.         dummy.select();
  20.         document.execCommand('copy');
  21.         document.body.removeChild(dummy);
  22.     }
  23.     window.copyall = function() {
  24.         window.copyToClipboard(Array.from(document.querySelectorAll('#main .content li')).map(x=>{
  25.             return [x.children[0], x.children[1], x.children[2], x.children[4],].map(c => {
  26.                 return c.innerHTML.split(/&nbsp;&nbsp;(.*?)</)[1]
  27.             }).join(',')
  28.         }).join('\r\n'))
  29.     }
  30. })();
Advertisement
Add Comment
Please, Sign In to add comment