Greasy Fork is available in English.

Wayback Machine links modifier

Modifies WM links on a result page to redirect to actual website, not the snapshot

  1. // ==UserScript==
  2. // @name Wayback Machine links modifier
  3. // @description Modifies WM links on a result page to redirect to actual website, not the snapshot
  4. // @include /http://web\.archive\.org/web/\d{14}/http(|s)://.*$/
  5. // @author iceman94
  6. // @copyright 2017+, iceman94
  7. // @version 0.1
  8. // @grant none
  9. // @namespace https://greatest.deepsurf.us/users/148290
  10. // ==/UserScript==
  11.  
  12.  
  13. //=======================================================================================================
  14. // Cross-browsers load function
  15. // Tests in this order :
  16. // -support for jQuery API
  17. // |-uses $(window).load method if available
  18. // |-uses $(window).ready method if available
  19. // -support for DOMContentLoaded event (compatible only with the following browsers :
  20. // Chrome >= 0.2; Firefox >= 1.0; IE >= 9.0; Opera >= 9.0; Safari >= 3.1)
  21. // -support for document.attachEvent
  22. // -uses setTimeout w/ 5000ms delay
  23. //=======================================================================================================
  24.  
  25. function XBLoad(func, verbose)
  26. {
  27. verbose = verbose || false;
  28.  
  29. if (window.jQuery)
  30. {
  31. if ($(window).load)
  32. {
  33. if (verbose == true) { console.log('Javascript loaded using $(window).load method'); };
  34. return $(window).load(function() { func(); });
  35. }
  36. else if ($(window).ready)
  37. {
  38. if (verbose == true) { console.log('Javascript loaded using $(window).ready method'); };
  39. return $(window).ready(function() { func(); });
  40. };
  41. }
  42. else if (document.addEventListener)
  43. {
  44. if (verbose == true) { console.log('Javascript loaded using document.addEventListener method'); };
  45. document.addEventListener('DOMContentLoaded', function(event)
  46. {
  47. return func();
  48. });
  49. }
  50. else if (document.attachEvent)
  51. {
  52. if (verbose == true) { console.log('Javascript loaded using document.attachEvent method'); };
  53. document.attachEvent('load', function()
  54. {
  55. return func();
  56. });
  57. }
  58. else
  59. {
  60. if (verbose == true) { console.log('Javascript loaded using setTimeout method'); };
  61. return setTimeout(function() { func(); }, 5000);
  62. };
  63. };
  64.  
  65.  
  66. //=======================================================================================================
  67. // Setting up functions
  68. //=======================================================================================================
  69.  
  70. // Modifies WM links on a result page to redirect to the actual website linked, not the snapshot
  71. function rewriteLinks()
  72. {
  73. var coll = document.getElementsByTagName('a');
  74. var l = coll.length;
  75. for (var i=0; i<l; i++)
  76. {
  77. if(coll[i].href && coll[i].href.search(/^http:\/\/web\.archive\.org\/web\/\d{14}\/.*/i) != -1)
  78. {
  79. //console.log('Matching result: ', coll[i].href);
  80. coll[i].href = coll[i].href.replace(/^http:\/\/web\.archive\.org\/web\/\d{14}\//i, "");
  81. }
  82. }
  83. };
  84.  
  85.  
  86. //=======================================================================================================
  87. // Showtime !
  88. //=======================================================================================================
  89.  
  90. XBLoad(rewriteLinks());