Wayback Machine Favicon Fixer

Attempts to add a favicon to a site crawled by the Wayback Machine in the event one does not come up normally

  1. // ==UserScript==
  2. // @name Wayback Machine Favicon Fixer
  3. // @namespace DoomTay
  4. // @description Attempts to add a favicon to a site crawled by the Wayback Machine in the event one does not come up normally
  5. // @version 1.3.0
  6. // @include http://web.archive.org/web/*
  7. // @include http://wayback.archive.org/web/*
  8. // @include https://web.archive.org/web/*
  9. // @include https://wayback.archive.org/web/*
  10. // @exclude /\*/
  11. // @grant GM_addElement
  12. // @noframes
  13.  
  14. // ==/UserScript==
  15.  
  16. var timestamp = /web\/(\d{1,14})/.exec(window.location.href)[1];
  17.  
  18. var originalDomain = /.+web\/\d+(?:[a-z][a-z]_)?\/((?:https?:\/\/)?[^\/]+)/.exec(window.location.href)[1];
  19.  
  20. if(!originalDomain.endsWith("/")) originalDomain = originalDomain + "/";
  21.  
  22. if(!document.querySelector("link[rel~='icon']") && document.contentType == "text/html") retrieveFavicon();
  23.  
  24. function retrieveFavicon()
  25. {
  26. fetch("https://archive.org/wayback/available?url=" + encodeURIComponent(originalDomain + "favicon.ico") + "&timestamp=" + timestamp).then(result => result.json()).then(function(data)
  27. {
  28. if(data.archived_snapshots && data.archived_snapshots.closest && data.archived_snapshots.closest.available)
  29. {
  30. GM_addElement("link",
  31. {type: "image/x-icon",
  32. rel: "shortcut icon",
  33. href: data.archived_snapshots.closest.url.replace("http:","https:").replace("/ht","mp_/ht")
  34. });
  35. }
  36. })
  37. }

QingJ © 2025

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