Single Page Everything

Load single page version of page for supported sites

目前为 2023-04-19 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Single Page Everything
  3. // @namespace @leesei/userscripts
  4. // @version 2.0.0
  5. // @description Load single page version of page for supported sites
  6. // @author leesei@gmail.com
  7. // @supportURL https://github.com/leesei/userscripts/issues
  8. // @match http*://*.howstuffworks.com/*
  9. // @match http*://www.anandtech.com/show/*
  10. /// @match http*://www.tomshardware.com/reviews/*.html
  11. // @match http*://learn.adafruit.com/*
  12. // @match http*://learn.sparkfun.com/tutorials/*
  13. // @match http*://arstechnica.com/*
  14. // @run-at document-start
  15. // @grant GM_log
  16. // @grant GM_info
  17. // @noframes
  18. // ==/UserScript==
  19.  
  20. function log(level, text) {
  21. GM_log(level + ": " + text);
  22. }
  23.  
  24. const handlers = {
  25. howstuffworks: function (params) {
  26. if (!location.pathname.endsWith(".htm")) return;
  27.  
  28. const links = document.querySelectorAll("a[rel='nofollow']");
  29. for (const link of links) {
  30. if (link.innerText == "Print") {
  31. return location.replace(link.href);
  32. }
  33. }
  34. },
  35. anandtech: function (params) {
  36. location.replace(location.pathname.replace("/show", "/print"));
  37. },
  38. // tomshardware: function (params) {
  39. // location.replace(
  40. // location.pathname.replace("/reviews", "/print").replace(",", ",reviews-")
  41. // );
  42. // },
  43. adafruit: function (params) {
  44. const links = document.querySelectorAll(
  45. "ul[aria-label='Guide resources'] li a"
  46. );
  47. for (const link of links) {
  48. if (link.innerText == "Single page") {
  49. return location.replace(link.href);
  50. }
  51. }
  52. },
  53. sparkfun: function (params) {
  54. const links = document.querySelectorAll("a.list-group-item");
  55. for (const link of links) {
  56. if (link.innerText == "Single Page") {
  57. return location.replace(link.href);
  58. }
  59. }
  60. },
  61. arstechnica: function (params) {
  62. const link = document.querySelector("link[rel='amphtml']");
  63. if (link) location.replace(link.href);
  64. },
  65. };
  66.  
  67. (function () {
  68. "use strict";
  69.  
  70. log(
  71. "info",
  72. ">>> [" + GM_info.script.namespace + "] " + GM_info.script.name + " <<<"
  73. );
  74.  
  75. const params = new URLSearchParams(location.search);
  76. // log("info", JSON.stringify(params.entries()));
  77.  
  78. for (const domain in handlers) {
  79. if (location.hostname.includes(domain)) {
  80. handlers[domain](params);
  81. break;
  82. }
  83. }
  84. })();

QingJ © 2025

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