Automatic Save to Wayback Machine

Automatically saves the pages you visit into the Wayback Machine.

  1. // ==UserScript==
  2. // @name Automatic Save to Wayback Machine
  3. // @namespace Zopolis4
  4. // @description Automatically saves the pages you visit into the Wayback Machine.
  5. // @version 2.1.0
  6. // @match *
  7. // @grant GM_xmlhttpRequest
  8. // @require https://gitcdn.link/repo/uwx/GM_fetch.ts/fe0cd27fa60efc2975fea55a03d8545ae61aaf34/dist/GM_fetch.js
  9. // @run-at document-start
  10. // ==/UserScript==
  11.  
  12. function parseURLs() {
  13. var url = "https://web.archive.org/save/" + location.href;
  14. if (location.hostname == "web.archive.org") {
  15. url = "https://web.archive.org/save/" + encodeURI(decodeURI(location.href).replace(/(https?:\/\/)?(www\.)?web\.archive\.org\/(|save|web\/\*\/[0-9]+|web\/[0-9]+|\*\/[0-9]+|web\/\*\/|web|\*\/|[0-9]+)?(\/|id_\/)?/, ""));
  16. }
  17. savePages(url);
  18. }
  19. function savePages(url) {
  20. fetch(url, {
  21. method: "GET",
  22. headers: {"Content-Type": "application/x-www-form-urlencoded"}
  23. });
  24. console.log(url);
  25. }
  26.  
  27. document.addEventListener("DOMContentLoaded", parseURLs);