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.

当前为 2021-06-30 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Google Image Direct Link Patch
  3. // @namespace GoogleImageDirectLinkPatch
  4. // @version 1.2.6
  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/
  10. // @include /^https:\/\/www\.google\.com(\.[a-z]{2,3})?\/search.*tbm=isch/
  11. // @grant none
  12. // @run-at document-start
  13. // ==/UserScript==
  14.  
  15. ((idat, ap, xo) => {
  16. function processEntries() {
  17. document.querySelectorAll(".isv-r:not(.paneled)").forEach((e, a, id, d) => {
  18. e.classList.add("paneled_gidlp");
  19. e.insertBefore(a = document.createElement("A"), e.firstChild).className = "panel_gidlp";
  20. a.dataset.ow = e.dataset.ow;
  21. a.dataset.oh = e.dataset.oh;
  22. a.rel = "nofollow noopener noreferrer";
  23. id = e.dataset.id;
  24. if (!idat.some((d, i) => {
  25. if (d[7] === id) {
  26. a.href = d[1][3][0];
  27. idat.splice(i, 1);
  28. return true
  29. }
  30. })) a.href = 'javascript:void("Image URL is not found")';
  31. })
  32. }
  33.  
  34. ap = Array.prototype.push;
  35. Array.prototype.push = function(v) {
  36. if (!idat && v.key && v.hash && v.sideChannel && v.data && v.data[31]) idat = v.data[31][0][12][2].slice();
  37. return ap.apply(this, arguments);
  38. };
  39.  
  40. xo = XMLHttpRequest.prototype.open;
  41. XMLHttpRequest.prototype.open = function(mtd, url) {
  42. if (/\/_\/VisualFrontendUi\/data\/batchexecute/.test(url)) {
  43. this.addEventListener("load", (a, z) => {
  44. if (a = this.responseText.split("\n")[3]) try {
  45. Array.prototype.push.apply(idat, a = JSON.parse(JSON.parse(a)[0][2])[31][0][12][2]);
  46. } catch(z) {}
  47. })
  48. }
  49. return xo.apply(this, arguments);
  50. };
  51.  
  52. addEventListener("load", (a, mo, ht) => {
  53. if ((a = document.querySelectorAll(".islrc,.islrh")).length) {
  54. document.documentElement.appendChild(b = document.createElement("STYLE")).id = "css_gidpl";
  55. b.innerHTML = `
  56. .isv-r.paneled_gidlp>.panel_gidlp {
  57. position: absolute; z-index: 1; right: 0; bottom: 3.1em; font-size: 10pt; line-height: normal;
  58. }
  59. .isv-r.paneled_gidlp>.panel_gidlp:before {
  60. border-radius: .2em; padding: 0 .3ex; background-color: #444; color: #fff; content: attr(data-ow) "x" attr(data-oh);
  61. }`;
  62. mo = new MutationObserver(recs => {
  63. clearTimeout(ht);
  64. ht = setTimeout(processEntries, 500);
  65. });
  66. a.forEach(e => mo.observe(e, {childList: true}));
  67. processEntries();
  68. }
  69. });
  70. })();

QingJ © 2025

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