Single Page Everything

Load single page version of page for supported sites

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

作者のサイトでサポートを受ける。または、このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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;
    }
  }
})();