srikat icon

Untitled

srikat | PRO | 03/30/21 10:54:21 PM UTC | 0 ⭐ | 909 👁️ | Never ⏰ | []
JavaScript |

870 B

|

None

|

0 👍

/

0 👎

// ==UserScript==
// @name        New script - google.com
// @namespace   Violentmonkey Scripts
// @match       *://*.google.com/search?*
// @grant       none
// @version     1.0
// @author      -
// @description 31/03/2021, 09:05:03
// @require     https://code.jquery.com/jquery-3.6.0.min.js
// ==/UserScript==
 
(function() {
    'use strict';
    
    // Function to copy the passed string to clipboard.
    function copyToClipboard(string) {
        let $temp = $('<input>');
 
        $('body').append($temp);
        
        $temp.val(string).select();
                                                            
        document.execCommand('copy');
 
        $temp.remove();
    }
 
    $('.wsn-google-focused-link a, .yuRUbf a').each(function() {
    let $linkString = $(this).attr('href');
    
    //console.log($linkString);
        
    $('<button onclick="copyToClipboard($linkString)">Copy URL</button>').insertAfter($(this).find('h3'));
    });
 
})();

Comments