SHARE
TWEET

Afficher l'image

Zalati Feb 18th, 2018 (edited) 1,239 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Afficher l'image
  3. // @namespace    affiche-image
  4. // @version      1.0.0
  5. // @description  Remet le bouton "Afficher l'image" sur Google image
  6. // @author       Zalati
  7. // @include      /^https://(.*).google.([a-z\.]*)/(imgres|search)(.*)
  8. // @downloadURL  https://pastebin.com/raw/Th5SrkPf
  9. // @updateURL    https://pastebin.com/raw/Th5SrkPf
  10. // @grant        none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15.     'use strict';
  16.  
  17.     let buttonClass = "view_button";
  18.  
  19.     let imageObserver = new MutationObserver(function(mutations) {
  20.         mutations.forEach(function(mutation) {
  21.             //console.log(mutation);
  22.             if(mutation.target.src !== "" && mutation.target.classList.contains('irc_mi')) {
  23.                 let container = mutation.target.closest('.irc_c');
  24.  
  25.                 let span = document.createElement('span');
  26.                 span.textContent = 'Afficher l\'image';
  27.  
  28.                 let btn = document.createElement('a');
  29.                 btn.className += buttonClass;
  30.                 btn.target = '_blank';
  31.                 btn.href = mutation.target.src;
  32.                 btn.appendChild(span);
  33.  
  34.                 let td = document.createElement('td');
  35.                 td.appendChild(btn);
  36.  
  37.                 let menu = container.querySelector('table.irc_but_r tbody tr');
  38.                 let existBtn = menu.querySelector("."+buttonClass);
  39.                 if(existBtn) {
  40.                     existBtn.parentNode.removeChild(existBtn);
  41.                 }
  42.  
  43.                 menu.insertAdjacentElement('afterbegin', td);
  44.  
  45.             }
  46.         });
  47.     });
  48.  
  49.     imageObserver.observe(document.body, {
  50.         attributes: true,
  51.         subtree: true,
  52.         attributeFilter: ['src']
  53.     });
  54.  
  55. })();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top