Advertisement
srikat

Untitled

Mar 30th, 2021
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        New script - google.com
  3. // @namespace   Violentmonkey Scripts
  4. // @match       *://*.google.com/search?*
  5. // @grant       none
  6. // @version     1.0
  7. // @author      -
  8. // @description 31/03/2021, 09:05:03
  9. // @require     https://code.jquery.com/jquery-3.6.0.min.js
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.     'use strict';
  14.    
  15.     // Function to copy the passed string to clipboard.
  16.     function copyToClipboard(string) {
  17.         let $temp = $('<input>');
  18.  
  19.         $('body').append($temp);
  20.        
  21.         $temp.val(string).select();
  22.                                                            
  23.         document.execCommand('copy');
  24.  
  25.         $temp.remove();
  26.     }
  27.  
  28.     $('.wsn-google-focused-link a, .yuRUbf a').each(function() {
  29.     let $linkString = $(this).attr('href');
  30.    
  31.     //console.log($linkString);
  32.        
  33.     $('<button onclick="copyToClipboard($linkString)">Copy URL</button>').insertAfter($(this).find('h3'));
  34.     });
  35.  
  36. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement