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.

Από την 18/04/2023. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        Google Image Direct Link Patch
// @namespace   GoogleImageDirectLinkPatch
// @version     1.2.14
// @license     AGPL v3
// @author      jcunews
// @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.
// @website     https://greasyfork.org/en/users/85671-jcunews
// @include     /^https:\/\/www\.google\.(co\.)?[a-z]{2,3}\/search.*tbm=isch/
// @include     /^https:\/\/www\.google\.com(\.[a-z]{2,3})?\/search.*tbm=isch/
// @grant       none
// @run-at      document-start
// ==/UserScript==

((idat, ap, xo) => {
  function processEntries() {
    if (!idat) return;
    document.querySelectorAll("div.isv-r[data-ow]:not(.paneled_gidlp)").forEach((e, a, id, d) => {
      e.classList.add("paneled_gidlp");
      e.insertBefore(a = document.createElement("A"), e.firstChild).className = "panel_gidlp";
      a.dataset.ow = e.dataset.ow;
      a.dataset.oh = e.dataset.oh;
      a.rel = "nofollow noopener noreferrer";
      id = e.dataset.id;
      if (!idat.some((d, i, v) => {
        if ((v = d[0]) && (v = v[0]) && (v = v[444383007]) && (v = v[1]) && (v[1] === id)) {
          a.href = v[3][0];
          idat.splice(i, 1);
          return true
        } else if (d[7] === id) {
          a.href = (d[1].Ve && d[1].Ve[3] && d[1].Ve[3][0]) || (d[1][3] && d[1][3][0]) ||
            ((v = d[0]) && (v = v.Ve) && (v = v[0]) && (v = v[444383007]) && (v = v.Ve) && (v = v[1]) && (v = v.Ve) && (v = v[3]) && (v = v[0]));
          idat.splice(i, 1);
          return true
        }
      })) a.href = 'javascript:void("Image URL is not found")';
    })
  }

  function getArr(v, w) {
    if (v[2]) {
      return v[2].slice()
    } else return Object.values(v).reduce((r, v) => {
      if (Array.isArray(v)) {
        if (v[2]) {
          r = v[2].slice()
        } else if (v[0] && v[0].sort) r = v[0].slice()
      }
      return r
    }, null)
  }

  function getData(v, w) {
    if (v && v.key && v.hash && v.sideChannel && (v = v.data)) {
      if ((w = v[31]) && (w = w[0]) && (w = w[12])) return !!(idat = getArr(w))
      if ((w = v[56]) && (w = w[1]) && (w = w[0]) && (w = w[0])) return !!(idat = getArr(w))
    }
  }

  ap = Array.prototype.push;
  Array.prototype.push = function(v) {
    if (!idat) getData(v);
    return ap.apply(this, arguments);
  };

  xo = XMLHttpRequest.prototype.open;
  XMLHttpRequest.prototype.open = function(mtd, url) {
    if (/\/_\/VisualFrontendUi\/data\/batchexecute/.test(url)) {
      this.addEventListener("load", (v, z) => {
        if (v = this.responseText.split("\n")[3]) try {
          v = JSON.parse(JSON.parse(v)[0][2]);
          if (w = v[56][1][0][0]) {
            ap.apply(idat, getArr(w));
          } else if (w = v[31][0][12]) ap.apply(idat, getArr(w));
        } catch(z) {}
      })
    }
    return xo.apply(this, arguments);
  };

  addEventListener("load", (a, mo, ht) => {
    if (a = document.querySelector("#wiz_jd").previousElementSibling.text.match(/AF_initDataCallback\((.*?)\);\s*$/)) {
      getData((new Function("return " + a[1]))());
    }
    if ((a = document.querySelectorAll(".islrc,.islrh")).length) {
      document.documentElement.appendChild(b = document.createElement("STYLE")).id = "css_gidpl";
      b.innerHTML = `
.isv-r.paneled_gidlp>.panel_gidlp {
 position: absolute; z-index: 1; right: 0; bottom: 3.1em; font-size: 10pt; line-height: normal;
}
.isv-r.paneled_gidlp>.panel_gidlp:before {
  border-radius: .2em; padding: 0 .3ex; background-color: #444; color: #fff; content: attr(data-ow) "x" attr(data-oh);
}`;
      mo = new MutationObserver(recs => {
        clearTimeout(ht);
        ht = setTimeout(processEntries, 500);
      });
      a.forEach(e => mo.observe(e, {childList: true}));
      processEntries();
    }
  });
})();