Advertisement
Guest User

Untitled

a guest
Apr 20th, 2022
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. // ==UserScript==
  2. // @name images tool insta9999
  3. // @namespace ale
  4. // @version 1
  5. // @description -
  6. // @author -
  7. // @require http://code.jquery.com/jquery-3.6.0.min.js
  8. // @include https://www.google.com/search?tbm=isch&q=*#imgrc=*
  9. // @match https://*instagram.com/*
  10. // @grant GM_setClipboard
  11. // @grant GM_download
  12. // @inject-into content
  13. // @run-at document-idle
  14. // ==/UserScript==
  15. (() => { let LAST_VISITED_URL = window.location.href;
  16.  
  17. setInterval(() => {
  18. if(window.location.href != LAST_VISITED_URL){
  19. handleNewPage(window.location);
  20.  
  21. LAST_VISITED_URL = window.location.href;
  22. }
  23. }, 500);
  24.  
  25. const handleNewPage = page => {
  26. console.log("Host:", page.host, "Hash", page.hash);
  27.  
  28. switch(page.host) {
  29. case "www.google.com":
  30. handleGoogle();
  31. break;
  32. case "www.instagram.com":
  33. handleInstagram();
  34. break;
  35. // more sites...
  36. }
  37. };
  38.  
  39. })();
  40.  
  41. function handleGoogle() { console.log("$('body').on('click','img', displayContextMenu);
  42. function displayContextMenu(e) {
  43. e.preventDefault();
  44. currentTarget = e.target;
  45. var srcd = $(currentTarget).prop("src");GM_setClipboard(srcd);
  46. }
  47. });"); }
  48.  
  49. function handleInstagram() { console.log("$('body').on('click','img', displayContextMenu);
  50. function displayContextMenu(e) {
  51. e.preventDefault();
  52. currentTarget = e.target;
  53. var srcd = $(currentTarget).prop("src");GM_setClipboard(srcd);
  54. }
  55. });"); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement