Copy URL Buttons in Google Search Results

Makes copying links from google search results faster by adding 1-click copy buttons next to the results

  1. // ==UserScript==
  2. // @name Copy URL Buttons in Google Search Results
  3. // @namespace https://wpdevdesign.com/
  4. // @match *://*.google.*/search?*
  5. // @grant none
  6. // @version 1.0.1
  7. // @author Abdelouahed Errouaguy & Sridhar Katakam
  8. // @description Makes copying links from google search results faster by adding 1-click copy buttons next to the results
  9. // ==/UserScript==
  10.  
  11. /* jshint esversion: 6 */
  12.  
  13. (function () {
  14. 'use strict';
  15. // Function to copy the passed string to clipboard.
  16. function copyToClipboard(event) {
  17. let helper = document.createElement('input');
  18.  
  19. document.body.appendChild(helper);
  20. helper.value = this.value;
  21. helper.select();
  22. document.execCommand('copy');
  23. this.textContent = "Copied ✓";
  24. helper.remove();
  25. event.preventDefault();
  26. event.stopPropagation();
  27. }
  28.  
  29. document.querySelectorAll('.wsn-google-focused-link > a, .yuRUbf > div a').forEach(el => {
  30. let href = el.href;
  31. let button = document.createElement("button");
  32. button.textContent = "Copy URL";
  33. button.value = href;
  34. button.style.cssText = "cursor: pointer; margin-left: 10px; border-radius: 12px; padding: 4px 12px; border: 1px solid #ccc; font-size: 12px; position: absolute;";
  35. button.addEventListener("click", copyToClipboard);
  36. el.querySelector("h3").appendChild(button);
  37. });
  38. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址