Auto Archive Website

Automatically saves pages to Internet Archive while browsing the web.

  1. // ==UserScript==
  2. // @name Auto Archive Website
  3. // @description Automatically saves pages to Internet Archive while browsing the web.
  4. // @namespace Auto Archive Website by BebiBear
  5. // @run-at document-start
  6. // @match http://*/*
  7. // @match https://*/*
  8. // @exclude http://web.archive.org/*
  9. // @exclude https://web.archive.org/*
  10. // @version 1.1.0
  11. // @grant GM.xmlHttpRequest
  12. // ==/UserScript==
  13.  
  14. (function() {
  15.  
  16. GM.xmlHttpRequest({
  17. method: 'GET',
  18. url: 'https://web.archive.org/save/' + location.href,
  19. onload: function(response) {
  20. if (response.status == 200) {
  21. console.log('Website saved to Internet Archive');
  22. }
  23. }
  24. });
  25.  
  26. window.addEventListener('load', function() {
  27. var links = document.getElementsByTagName('a');
  28. for (var i = 0; i < links.length; i++) {
  29. links[i].addEventListener('click', function addToArchive(event) {
  30. GM.xmlHttpRequest({
  31. method: 'GET',
  32. url: 'https://web.archive.org/save/' + event.target.href,
  33. onload: function(response) {
  34. if (response.status == 200) {
  35. console.log('Website saved to Internet Archive');
  36. }
  37. }
  38. });
  39. }, false);
  40. }
  41. }, false);
  42.  
  43. })();