Advertisement
Sixem

Userscript: Arhivach.cf Image Options (Reverse + DDL)

Aug 13th, 2018
706
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Arhivach Image Options
  3. // @version      0.1
  4. // @description  Adds direct download button and reverse image search options
  5. // @author       Π΅ΠΌΡƒ
  6. // @match        https://arhivach.cf/thread/*
  7. // @require      https://code.jquery.com/jquery-3.2.1.min.js
  8. // @require      https://use.fontawesome.com/releases/v5.0.10/js/all.js
  9. // ==/UserScript==
  10.  
  11. this.$ = this.jQuery = jQuery.noConflict(true);
  12.  
  13. function getReverseImageSearchOptions(url)
  14. {
  15.     var options = {
  16.         'google': 'https://www.google.com/searchbyimage?image_url=' + url + '&safe=off',
  17.         'yandex': 'https://www.yandex.com/images/search?rpt=imageview&img_url=' + url,
  18.         'iqdb': 'https://iqdb.org/?url=' + url
  19.     };
  20.  
  21.     return options;
  22. }
  23.  
  24. var re = new RegExp('(mp4|webm)');
  25.  
  26. $(document).ready(function(){
  27.  
  28.   var use_style = 'text-decoration: none; margin-left: 5px; font-size: 10px;';
  29.  
  30.   $(".post_image_block").each(function(index)
  31.   {
  32.     var file_url = $(this).find('.img_filename');
  33.  
  34.     if(file_url != undefined) {
  35.         $reverse_options = getReverseImageSearchOptions(file_url.attr('href'));
  36.  
  37.         if(re.test(file_url.attr('href')))
  38.         {
  39.           $reverse_options = getReverseImageSearchOptions($(this).find('.post_image > img').attr('src'));
  40.         }
  41.  
  42.         var first_c = $(this).find(">:first-child");
  43.  
  44.         var direct_download = '<a style="' + use_style + '" href="' + file_url.attr('href')  + '" download="' + file_url.text() + '"><i title="Download: ' + file_url.text() + '" class="fa fa-download"></i></a>';
  45.         var r_google = '<a style="' + use_style + '" target="_blank" href="' + $reverse_options['google']  + '"><i title="Google" class="fab fa-google"></i></a>';
  46.         var r_yandex = '<a style="' + use_style + '" target="_blank" href="' + $reverse_options['yandex']  + '"><i title="Yandex" class="fab fa-yandex-international"></i></a>';
  47.  
  48.         first_c.after(direct_download + r_google + r_yandex);
  49.  
  50.     }
  51.   });
  52.  
  53. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement