archive.today auto-click

Helper for loading archive.today URLs - auto-clicks the 'save' button to go to the archive

  1. // ==UserScript==
  2. // @name archive.today auto-click
  3. // @namespace http://tampermonkey.net/ // Changed namespace to a generic placeholder
  4. // @match https://archive.today/?*
  5. // @match https://archive.fo/?*
  6. // @match https://archive.is/?*
  7. // @match https://archive.li/?*
  8. // @match https://archive.md/?*
  9. // @match https://archive.ph/?*
  10. // @match https://archive.vn/?*
  11. // @match https://archiveiya74codqgiixo33q62qlrqtkgmcitqx5u2oeqnmn5bpcbiyd.onion/?*
  12. // @grant none
  13. // @icon https://archive.today/apple-touch-icon.png
  14. // @version 1.3
  15. // @author ccuser44, richd
  16. // @license CC0
  17. // @description Helper for loading archive.today URLs - auto-clicks the 'save' button to go to the archive
  18. // ==/UserScript==
  19.  
  20. /*
  21. * This script is a modified version of "archive.today quick archive" v1.2
  22. * originally by ccuser44.
  23. * Source of original script: https://greasyfork.org/scripts/512123-archivetoday-quick-archive
  24. *
  25. * Modifications by Rich include:
  26. * - Updating @match patterns to explicitly list domains for better reliability.
  27. * - Adding check to only click save button if URL input is pre-populated.
  28. * - Removing unnecessary DOMContentLoaded listener and setTimeout.
  29. * - Adding a simple emoji indicator appended to the button text when clicked.
  30. * - Updating description and author list.
  31. *
  32. * Original license (CC0) is retained.
  33. *
  34. * To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide.
  35. * This software is distributed without any warranty.
  36. * You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.archive.org/publicdomain/zero/1.0/>.
  37. */
  38.  
  39. (function() {
  40. 'use strict';
  41. console.debug("archive.today auto-click script started");
  42. const form = document.getElementById('submiturl');
  43. const urlInput = document.getElementById('url');
  44. if (form && urlInput) {
  45. // Only click the form if there is a populated URL, which will happen when the page is loaded with 'url=<URL>' as a query parameter
  46. const urlValue = urlInput.value;
  47. if (urlValue && urlValue.trim() !== '') {
  48. console.log(`Loading archive for: "${urlValue}"...`);
  49. const saveButton = form.querySelector('input[type="submit"][value="save"]');
  50. if (saveButton) {
  51. saveButton.value = saveButton.value + ' ⏳'; // Add emoji to indicate loading
  52. saveButton.click();
  53. console.debug("Clicked the Save button.");
  54.  
  55. } else {
  56. console.error("Failed to find Save button for auto-clicking.");
  57. }
  58. } else {
  59. console.debug("No URL set, so not auto-clicking.");
  60. }
  61. } else {
  62. console.error("Failed to find form needed for auto-clicking.");
  63. }
  64. })();