DuckDuckgGo Image Direct Link Patch

Make DuckDuckgGo Image search result entry's image size information as link to the direct image resource.

Mint 2021.07.03.. Lásd a legutóbbi verzió

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        DuckDuckgGo Image Direct Link Patch
// @namespace   https://greasyfork.org/en/users/85671-jcunews
// @version     1.0.2
// @license     AGPL v3
// @author      jcunews
// @description Make DuckDuckgGo Image search result entry's image size information as link to the direct image resource.
// @match       https://duckduckgo.com/*
// @grant       none
// @run-at      document-start
// ==/UserScript==

((dt, xo, mo, ht) => {
  function processEntries() {
    if (!dt) {
      clearTimeout(ht);
      ht = setTimeout(processEntries, 500);
      return;
    }
    document.querySelectorAll(".tile--img>.tile--img__dimensions:not(.linked_didlp)").forEach((e, a, u) => {
      e.classList.add("linked_didlp");
      (a = document.createElement("A")).textContent = e.textContent;
      a.style.cssText = "color:inherit";
      a.rel = "nofollow noopener noreferrer";
      u = e.previousElementSibling.href;
      if (!dt.some((d, i) => {
        if (d.url === u) {
          a.href = d.image;
          dt.splice(i, 1);
          return true
        }
      })) a.href = 'javascript:void("Image URL is not found")';
      e.replaceChild(a, e.firstChild);
    });
  }

  xo = XMLHttpRequest.prototype.open;
  XMLHttpRequest.prototype.open = function(mtd, url) {
    if (/^\/?i\.js\?.*o=json/.test(url)) {
      this.addEventListener("load", (a, l, z) => {
        try {
          if (!(l = JSON.parse(this.responseText).results)) throw 0;
          Array.prototype.push.apply(dt, l);
        } catch(z) {}
        if (!mo) {
          mo = true;
          (new MutationObserver(recs => {
            clearTimeout(ht);
            ht = setTimeout(processEntries, 500);
          })).observe(document.body, {childList: true, subtree: true});
          processEntries();
        }
      })
    }
    return xo.apply(this, arguments);
  };

  dt = [];
})();