Greasy Fork is available in English.

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

2016-10-04 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name          Wayback Machine Favicon Fixer
// @namespace     DoomTay
// @description   Attempts to add a favicon to a site crawled by the Wayback Machine in the event one does not come up normally
// @version       1.2.0
// @include       http://web.archive.org/web/*
// @include       http://wayback.archive.org/web/*
// @include       https://web.archive.org/web/*
// @include       https://wayback.archive.org/web/*
// @exclude       /\*/
// @grant         none
// @noframes

// ==/UserScript==

var domain = window.location.href.substring(0,window.location.href.indexOf("/",window.location.href.lastIndexOf("//") + 2) + 1);
var timestamp = /web\/(\d{1,14})/.exec(window.location.href)[1];

var originalDomain = domain.substring(domain.lastIndexOf("http"));

if(!document.querySelector("link[rel~='icon']") && document.contentType == "text/html") retrieveFavicon();

function retrieveFavicon()
{
	function applyFavicon(data)
	{
		if (data.archived_snapshots && data.archived_snapshots.closest && data.archived_snapshots.closest.available)
		{
			var newFavicon = document.createElement('link');
			newFavicon.type = 'image/x-icon';
			newFavicon.rel = 'shortcut icon';
			newFavicon.href = data.archived_snapshots.closest.url;
			document.head.appendChild(newFavicon);
		}
	}
	
	var applyFaviconScript = document.createElement("script");
	applyFaviconScript.type = "text/javascript";
	applyFaviconScript.innerHTML = applyFavicon;
	document.head.appendChild(applyFaviconScript);
	
	var faviconScript = document.createElement("script");
	faviconScript.type = "application/javascript";
	faviconScript.src = "http://archive.org/wayback/available?url=" + encodeURI(originalDomain + "favicon.ico") + "&timestamp=" + timestamp + "&callback=applyFavicon";
	document.head.appendChild(faviconScript);
}