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.16
  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. if (!cd) return;
  18. cnt.querySelectorAll('div>h3:not(.paneled_gidlp)').forEach((e, a, o, id, d) => {
  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. })
  27. }
  28.  
  29. xo = XMLHttpRequest.prototype.open;
  30. XMLHttpRequest.prototype.open = function(mtd, url) {
  31. if (url.startsWith("/search?")) {
  32. this.addEventListener("load", (v, z) => {
  33. if ((v = this.responseText.split(";[")).length) try {
  34. JSON.parse("[" + v[v.length - 1])[0].forEach(a => {
  35. try {
  36. cd[a[0]] = JSON.parse(a[1])
  37. } catch(z) {}
  38. })
  39. } catch(z) {}
  40. })
  41. }
  42. return xo.apply(this, arguments)
  43. };
  44.  
  45. addEventListener("load", (a, mo, ht) => {
  46. if (Array.from(document.querySelectorAll('script:not([src])')).some(e => {
  47. if (e = e.text.match(/var [a-z]=(\{".*?\});/)) {
  48. cd = JSON.parse(e[1]);
  49. return true
  50. }
  51. })) {
  52. document.documentElement.appendChild(a = document.createElement("STYLE")).id = "css_gidpl";
  53. a.innerHTML = `
  54. #rso div>h3>.panel_gidlp {
  55. position: absolute; z-index: 1; right: 0; bottom: 0; font-size: 10pt; line-height: normal;
  56. }
  57. #rso div>h3>.panel_gidlp:before {
  58. border-radius: .2em; padding: 0 .3ex; background-color: #444; color: #fff; content: attr(data-ow) "x" attr(data-oh);
  59. }
  60. #rso div>h3>.panel_gidlp:visited:before {
  61. color: #f9f;
  62. }`
  63. }
  64. if (cnt = document.querySelector("#rso div[jsmodel][jsdata]")) {
  65. (mo = new MutationObserver(recs => {
  66. clearTimeout(ht);
  67. ht = setTimeout(processEntries, 500);
  68. })).observe(cnt, {childList: true});
  69. processEntries()
  70. }
  71. })
  72. })();

QingJ © 2025

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