Search with google image fix

Search with google image again cause fuck google lens

질문, 리뷰하거나, 이 스크립트를 신고하세요.
  1. // ==UserScript==
  2. // @name Search with google image fix
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1.3
  5. // @description Search with google image again cause fuck google lens
  6. // @author You
  7. // @require http://code.jquery.com/jquery-3.4.1.min.js
  8. // @match http://*/*
  9. // @match https://*/*
  10. // @exclude https://www.instant-gaming.com/*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. var invert = true;
  15.  
  16. function GM_addStyle(css) {
  17. const style = document.getElementById("GM_addStyle") || (function() {
  18. const style = document.createElement('style');
  19. style.type = 'text/css';
  20. style.id = "GM_addStyle";
  21. document.head.appendChild(style);
  22. return style;
  23. })();
  24. const sheet = style.sheet;
  25. sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
  26. }
  27.  
  28. (function() {
  29.  
  30. GM_addStyle(`
  31. .container__menu {
  32. /* Absolute position */
  33. position: absolute;
  34.  
  35. /* Reset */
  36. list-style: none;
  37. margin: 0;
  38. padding: 0;
  39. display: none;
  40.  
  41. /* Misc */
  42. border: 1px solid #cbd5e0;
  43. border-radius: 0.25rem;
  44. background-color: #f7fafc;
  45. }
  46. `);
  47.  
  48.  
  49. GM_addStyle(`
  50. .open {
  51. display: block;
  52. z-index: 9999;
  53. }
  54. `);
  55.  
  56. GM_addStyle(`
  57. .container__item {
  58. padding: 0.5rem 1rem;
  59. white-space: nowrap;
  60. cursor: pointer;
  61. color: black;
  62. }
  63. `);
  64.  
  65. GM_addStyle(`
  66. .container__item:hover {
  67. background-color: #bee3f8;
  68. }
  69. `);
  70.  
  71. GM_addStyle(`
  72. .container__divider {
  73. border-bottom: 1px solid #cbd5e0;
  74. height: 1px;
  75. }
  76. `);
  77.  
  78.  
  79. $("body").append(`
  80. <ul id="fucklens" class="container__menu">
  81. <li class="container__item">Search with google image</li>
  82. </ul>
  83. `);
  84.  
  85. var cntxtMn = $("#fucklens");
  86. var mouseX;
  87. var mouseY;
  88. var currentTarget = null;
  89.  
  90. $(document).mousemove(function(e) {
  91. mouseX = e.pageX;
  92. mouseY = e.pageY;
  93. });
  94. $("img").on('contextmenu', displayContextMenu);
  95.  
  96.  
  97. const observer = new MutationObserver(function(mutations_list) {
  98. mutations_list.forEach(function(mutation) {
  99. mutation.addedNodes.forEach(function(added_node) {
  100. var img = $(added_node).find("img");
  101. if (img){
  102. img.on('contextmenu', displayContextMenu);
  103. }
  104. });
  105. });
  106. });
  107.  
  108. observer.observe(document, { subtree: true, childList: true });
  109.  
  110. //thank you for this guy https://jsfiddle.net/JCJDesigns/6zsvmt10/
  111. function displayContextMenu(e) {
  112. (cntxtMn.hasClass("open")) ? cntxtMn.removeClass("open") : false;
  113. /*
  114. If inverte is true then ctrl key = special menu
  115. if invert is false then ctrl key = skip
  116.  
  117. */
  118. if (invert == false && e.ctrlKey)
  119. return;
  120.  
  121. else if (e.ctrlKey && invert)
  122. {
  123. cntxtMn.css({'top':mouseY,'left':mouseX}).addClass("open");
  124. e.preventDefault();
  125. currentTarget = e.target;
  126. return;
  127. }
  128. else if (invert == false){
  129. cntxtMn.css({'top':mouseY,'left':mouseX}).addClass("open");
  130. e.preventDefault();
  131. currentTarget = e.target;
  132. }
  133.  
  134. }
  135. cntxtMn.click(function(e) {
  136. e.stopPropagation();
  137. });
  138.  
  139. $(document).click(function() {
  140. (cntxtMn.hasClass("open")) ? cntxtMn.removeClass("open") : false;
  141. });
  142.  
  143. $(".container__item").click(function(){
  144. var src = "https://www.google.com/searchbyimage?image_url=" + $(currentTarget).prop("src");
  145. console.log($(currentTarget).prop("src"));
  146. (cntxtMn.hasClass("open")) ? cntxtMn.removeClass("open") : false;
  147. window.open(src);
  148. });
  149.  
  150.  
  151. })();