Greasy Fork 还支持 简体中文。

Search with google image fix

Search with google image again cause fuck google lens

目前為 2022-04-01 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Search with google image fix
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  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. // @grant none
  11. // ==/UserScript==
  12.  
  13. function GM_addStyle(css) {
  14. const style = document.getElementById("GM_addStyle") || (function() {
  15. const style = document.createElement('style');
  16. style.type = 'text/css';
  17. style.id = "GM_addStyle";
  18. document.head.appendChild(style);
  19. return style;
  20. })();
  21. const sheet = style.sheet;
  22. sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
  23. }
  24.  
  25. (function() {
  26.  
  27. GM_addStyle(`
  28. .container__menu {
  29. /* Absolute position */
  30. position: absolute;
  31.  
  32. /* Reset */
  33. list-style: none;
  34. margin: 0;
  35. padding: 0;
  36. display: none;
  37.  
  38. /* Misc */
  39. border: 1px solid #cbd5e0;
  40. border-radius: 0.25rem;
  41. background-color: #f7fafc;
  42. }
  43. `);
  44.  
  45.  
  46. GM_addStyle(`
  47. .open {
  48. display: block;
  49. }
  50. `);
  51.  
  52. GM_addStyle(`
  53. .container__item {
  54. padding: 0.5rem 1rem;
  55. white-space: nowrap;
  56. cursor: pointer;
  57. }
  58. `);
  59.  
  60. GM_addStyle(`
  61. .container__item:hover {
  62. background-color: #bee3f8;
  63. }
  64. `);
  65.  
  66. GM_addStyle(`
  67. .container__divider {
  68. border-bottom: 1px solid #cbd5e0;
  69. height: 1px;
  70. }
  71. `);
  72.  
  73.  
  74. $("body").append(`
  75. <ul id="fucklens" class="container__menu">
  76. <li class="container__item">Search with google image</li>
  77. </ul>
  78. `);
  79.  
  80. var cntxtMn = $("#fucklens");
  81. var mouseX;
  82. var mouseY;
  83. var currentTarget = null;
  84.  
  85. $(document).mousemove(function(e) {
  86. mouseX = e.pageX;
  87. mouseY = e.pageY;
  88. });
  89. $("img").on('contextmenu', displayContextMenu);
  90.  
  91. function displayContextMenu(e) {
  92. // Prevent the browser from opening it's own context menu
  93. e.preventDefault();
  94. currentTarget = e.target;
  95. // Display the context menu;
  96. // Use mouse X and Y position data to open the menu where the right-click event occurred
  97. cntxtMn.css({'top':mouseY,'left':mouseX}).addClass("open");
  98. }
  99. cntxtMn.click(function(e) {
  100. // Stop propagation allows users to click on the menu without the click event 'bubbling over';
  101. // I.E: stops the below function (that hides the menu with a left-click anywhere on the page)
  102. // from affecting user interaction with the context menu
  103. e.stopPropagation();
  104. });
  105.  
  106. $(document).click(function() {
  107. // Check if the context menu is open, and close it if it is (uses 'short-hand' if statement);
  108. // (conditionToTest) ? True Code : False Code;
  109. (cntxtMn.hasClass("open")) ? cntxtMn.removeClass("open") : false;
  110. });
  111.  
  112. $(".container__item").click(function(){
  113. var src = "https://www.google.com/searchbyimage?image_url=" + $(currentTarget).prop("src");
  114. window.open(src);
  115. });
  116.  
  117. /* $(document).mousedown(function(event) {
  118. if ($(event.target).prop("tagName").toUpperCase() == "IMG"){
  119. if (window.event.shiftKey ){
  120. var origSrc = addHostInformationIfNeeded($(event.target).attr("src"));
  121. console.log("orig: " + origSrc);
  122. var src = "https://www.google.com/searchbyimage?image_url=" + origSrc;
  123. window.open(src);
  124. event.preventDefault();
  125. return false;
  126. }
  127. }
  128. });*/
  129.  
  130.  
  131. })();