Wayback Machine

Add context menu option to open links in the latest archive on the Wayback Machine

  1. // ==UserScript==
  2. // @name Wayback Machine
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Add context menu option to open links in the latest archive on the Wayback Machine
  6. // @author sfortis
  7. // @match *://*/*
  8. // @grant GM_registerMenuCommand
  9. // @grant GM_openInTab
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. let lastRightClickedElement = null;
  17.  
  18. document.addEventListener('contextmenu', function(event) {
  19. lastRightClickedElement = event.target.closest('a'); // Capture the right-clicked link element
  20. }, true);
  21.  
  22. GM_registerMenuCommand("Open in Wayback Machine", function() {
  23. if (lastRightClickedElement && lastRightClickedElement.href) {
  24. const waybackUrl = `https://web.archive.org/web/2/${lastRightClickedElement.href}`; // "2" redirects to the latest archive
  25. GM_openInTab(waybackUrl, { active: true });
  26. }
  27. });
  28. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址