Single Page Everything

Load single page version of page for supported sites

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Single Page Everything
// @namespace    @leesei/userscripts
// @version      2.0.0
// @description  Load single page version of page for supported sites
// @author       [email protected]
// @license      MIT
// @supportURL   https://github.com/leesei/userscripts/issues
// @match        http*://*.howstuffworks.com/*
// @match        http*://www.anandtech.com/show/*
/// @match        http*://www.tomshardware.com/reviews/*.html
// @match        http*://learn.adafruit.com/*
// @match        http*://learn.sparkfun.com/tutorials/*
// @match        http*://arstechnica.com/*
// @run-at       document-start
// @grant        GM_log
// @grant        GM_info
// @noframes
// ==/UserScript==

function log(level, text) {
  GM_log(level + ": " + text);
}

const handlers = {
  howstuffworks: function (params) {
    if (!location.pathname.endsWith(".htm")) return;

    const links = document.querySelectorAll("a[rel='nofollow']");
    for (const link of links) {
      if (link.innerText == "Print") {
        return location.replace(link.href);
      }
    }
  },
  anandtech: function (params) {
    location.replace(location.pathname.replace("/show", "/print"));
  },
  // tomshardware: function (params) {
  //   location.replace(
  //     location.pathname.replace("/reviews", "/print").replace(",", ",reviews-")
  //   );
  // },
  adafruit: function (params) {
    const links = document.querySelectorAll(
      "ul[aria-label='Guide resources'] li a"
    );
    for (const link of links) {
      if (link.innerText == "Single page") {
        return location.replace(link.href);
      }
    }
  },
  sparkfun: function (params) {
    const links = document.querySelectorAll("a.list-group-item");
    for (const link of links) {
      if (link.innerText == "Single Page") {
        return location.replace(link.href);
      }
    }
  },
  arstechnica: function (params) {
    const link = document.querySelector("link[rel='amphtml']");
    if (link) location.replace(link.href);
  },
};

(function () {
  "use strict";

  log(
    "info",
    ">>> [" + GM_info.script.namespace + "] " + GM_info.script.name + " <<<"
  );

  const params = new URLSearchParams(location.search);
  // log("info", JSON.stringify(params.entries()));

  for (const domain in handlers) {
    if (location.hostname.includes(domain)) {
      handlers[domain](params);
      break;
    }
  }
})();