Greasy Fork镜像 还支持 简体中文。

Google Image Direct Link Patch

Readd Google Image search result entry's image bottom panel as bottom-right image size information and link it to the direct image resource.

  1. // ==UserScript==
  2. // @name Google Image Direct Link Patch
  3. // @namespace GoogleImageDirectLinkPatch
  4. // @version 1.3.18
  5. // @license AGPL v3
  6. // @author jcunews
  7. // @description Readd Google Image search result entry's image bottom panel as bottom-right image size information and link it to the direct image resource.
  8. // @website https://gf.qytechs.cn/en/users/85671-jcunews
  9. // @include /^https:\/\/www\.google\.(co\.)?[a-z]{2,3}\/search.*(tbm=isch|udm=2)/
  10. // @include /^https:\/\/www\.google\.com(\.[a-z]{2,3})?\/search.*(tbm=isch|udm=2)/
  11. // @grant none
  12. // @run-at document-start
  13. // ==/UserScript==
  14.  
  15. ((cnt, xo, cd) => {
  16. function processEntries() {
  17. cnt.querySelectorAll('div>h3:not(.paneled_gidlp)').forEach((e, a, o) => {
  18. if (cd) {
  19. e.classList.add("paneled_gidlp");
  20. e.insertBefore(a = document.createElement("A"), e.firstChild).className = "panel_gidlp";
  21. a.rel = "nofollow noopener noreferrer";
  22. o = cd[e.closest('[jsdata]').getAttribute("jsdata").match(/[^;]+$/)?.[0]]
  23. a.dataset.ow = o?.[1]?.[3]?.[2] || "???";
  24. a.dataset.oh = o?.[1]?.[3]?.[1] || "???";
  25. a.href = o?.[1]?.[3]?.[0] || 'javascript:void("Image URL is not found")';
  26. a.addEventListener("click", ev => {
  27. ev.stopImmediatePropagation();
  28. ev.stopPropagation();
  29. }, true)
  30. } else {
  31. (function wl(e, a, o) {
  32. if (o = e.closest('div[jscontroller]')?.__jscontroller?.pending?.value?.Vz?.Bp?.[1]?.Bp?.[3]) {
  33. e.classList.add("paneled_gidlp");
  34. if (!(a = e.querySelector('.panel_gidlp'))) e.insertBefore(a = document.createElement("A"), e.firstChild).className = "panel_gidlp";
  35. a.rel = "nofollow noopener noreferrer";
  36. a.dataset.ow = o[2] || "???";
  37. a.dataset.oh = o[1] || "???";
  38. a.href = o[0] || 'javascript:void("Image URL is not found")';
  39. a.addEventListener("click", ev => {
  40. ev.stopImmediatePropagation();
  41. ev.stopPropagation();
  42. }, true)
  43. } else setTimeout(wl, 100, e, a)
  44. })(e, a)
  45. }
  46. })
  47. }
  48.  
  49. xo = XMLHttpRequest.prototype.open;
  50. XMLHttpRequest.prototype.open = function(mtd, url) {
  51. if (url.startsWith("/search?")) {
  52. this.addEventListener("load", (v, z) => {
  53. if ((v = this.responseText.split(";[")).length) try {
  54. JSON.parse("[" + v[v.length - 1])[0].forEach(a => {
  55. try {
  56. cd[a[0]] = JSON.parse(a[1])
  57. } catch(z) {}
  58. })
  59. } catch(z) {}
  60. })
  61. }
  62. return xo.apply(this, arguments)
  63. };
  64.  
  65. addEventListener("load", (a, mo, ht) => {
  66. Array.from(document.querySelectorAll('script:not([src])')).some(e => {
  67. if (e = e.text.match(/var [a-z]=(\{".*?\});/)) {
  68. cd = JSON.parse(e[1]);
  69. return true
  70. }
  71. });
  72. document.documentElement.appendChild(a = document.createElement("STYLE")).id = "css_gidpl";
  73. a.innerHTML = `
  74. #rso div>h3>.panel_gidlp {
  75. position: absolute; z-index: 1; right: 0; bottom: 0; font-size: 10pt; line-height: normal;
  76. }
  77. #rso div>h3>.panel_gidlp:before {
  78. border-radius: .2em; padding: 0 .3ex; background-color: #444; color: #fff; content: attr(data-ow) "x" attr(data-oh);
  79. }
  80. #rso div>h3>.panel_gidlp:visited:before {
  81. color: #f9f;
  82. }`;
  83. if (cnt = document.querySelector("#rso div[jsmodel][jsdata]")) {
  84. (mo = new MutationObserver(recs => {
  85. clearTimeout(ht);
  86. ht = setTimeout(processEntries, 500);
  87. })).observe(cnt, {childList: true});
  88. processEntries()
  89. }
  90. })
  91. })()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址