NYT Single-Page Format v1.3

Rewrites New York Times links to ask for single page format. v1.3 imported from userscripts.org. Derived from bodosom.net version.

当前为 2014-06-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name NYT Single-Page Format v1.3
  3. // @version 1.3
  4. // @namespace http://www.greasyfork.org
  5. // @description Rewrites New York Times links to ask for single page format. v1.3 imported from userscripts.org. Derived from bodosom.net version.
  6. // @include http://*.nytimes.com/*
  7. // @include http://*nytimes.com/*
  8. // @include *nytimes.com*
  9. // ==/UserScript==
  10.  
  11. (function()
  12. {
  13. var xpath = "//a[contains(@href,'.html')]";
  14. var res = document.evaluate(xpath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  15. var i, link;
  16.  
  17. for (i = 0; link = res.snapshotItem(i); i++)
  18. {
  19. var add;
  20. if (link.href.search(/javascript/) >= 0)
  21. {
  22. //do nothing
  23. }
  24. else if (link.href.search(/index/) >= 0)
  25. {
  26. //do nothing
  27. }
  28. else if (link.href.search(/pagewanted=print/) >= 0)
  29. {
  30. //do nothing
  31. }
  32. else if (link.href.search(/\?/) >= 0)
  33. {
  34. add = '&';
  35. link.href = link.href + add + 'pagewanted=all';
  36. }
  37. else
  38. {
  39. add = '?';
  40. link.href = link.href + add + 'pagewanted=all';
  41. }
  42. }
  43. }
  44. )();