AntiUser / Bayanometr Image Search Context Menu

// ==UserScript==
// @name            Bayanometr Image Search Context Menu
// @namespace       https://openuserjs.org/scripts/AntiUser
// @description     Greasemonkey/Scriptish only. Add 'Inspect image by Baяnometr' in browser context menu when you right click on image to search joy.komato3.net with that image.
// @version         1.2.1
// @author          AntiUser
// @license     MIT
// @include         *
// @exclude         file://*
// @exclude         *bayanometr.xyz*
// @exclude         *coub.com*
// @exclude         *komato3.net*
// ==/UserScript==

/* RELEASE NOTES
  1.2.1
   * перенаправил на joy.komato3.net
  1.1
   * доработки для некоторых сайтов
  1.1.1
    * теперь coub'Ы точно работают :)
  1.1
    * баг не работали coub'Ы

 */

(function(){
  'use strict';
  if (!("contextMenu" in document.documentElement && "HTMLMenuItemElement" in window)){
    return;
  }
// потому что!
  var Head = document.getElementsByTagName('HEAD').item(0);
  var scrpt = document.createElement( 'script' );
  scrpt.setAttribute( 'src', "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" );
  scrpt.onload = function(){
    var menuID = 'userscript-search-bayan-by-image';
    var menuItemID = 'userscript-search-bayan-by-image_item';
    var $menuItem;
    var $body = $('body');
    $body.bind("contextmenu", initMenu);
    var $menu = $body.find('menu');
    if($menu.length === 0){
      $menu = $body.append('<menu id=' + menuID + ' type="context"></menu>').find('#' + menuID);
    }
    menuID = $menu.attr('id');
    $menu.append('<menuitem id="' + menuItemID + '"  label="Inspect image by Baяnometr"  icon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAB00lEQVQ4T42Tv4sTURDHZ96YIMLi/QUiggpis/t2AzYatNGzk7NRsLERRFEORfQ/8MdhpWchKBxoKRZaiKBYheQ9A3Jck8qzELFIdgm4kPe+ssGEeNmEvHKY7+c7M2+Gacar1+u7syy7CuAiMx8p0rz3myKy0e12n3Q6nbyIcZlea72PiN4D2GLmx0EQtIq8NE0TZr4J4GClUjnTaDR+TAH+ORsiem6MWavVaocGg8GyiLxuNps/C1AURbeI6FKapvEUQGu9CuCYtXYljuPLAKrOuVftdrs7Wa3W+g2AT1OAKIosM18XkV/OuVPGmKdlbYZheFxEHpVV8CcIgqU0Ta9471/sdB7BtNZ7vPe/ywB5EAR7+/3+0qjnGYMuB4RhaJj5hrX2y6wvLuJJkpwA8LBsBneZOTbGnJsHiOP4LYCP/wGSJDngnHsHYBczP7PWPphR/h3v/YUsy5IxYCRWSl0Tka08zz+LyDfv/ZpSarhISqkEwKpzbn+1Wl0eL9KkuNVqfdBanyWiwv0lM684544SEURkE8BGr9dbH6/yHPFpY8z3eXMY3oLW+isz397hvJB4BNgmosMATjLzfSJaWDwERFFUnOw9ItpWSp1fpOzJtv4CvTL35XIZ5dkAAAAASUVORK5CYII="></menuitem>');
    $menuItem = $menu.find("#" + menuItemID);
    $menuItem.on("click", function(event){
      window.open("http://joy.komato3.net/search?q=" + encodeURIComponent(event.target.getAttribute("imageURL")));
    });

    function initMenu(event) {
      var node = event.target;
      if (node.localName == "img") {
        $body.attr("contextmenu", menuID);
        $menuItem.attr("imageURL", node.src);
      } else {
        $body.removeAttr("contextmenu");
        $menuItem.removeAttr("imageURL");
      }
    }
  };
  Head.appendChild(scrpt);
})();