<iframe> click to load

NOT lazyload; click a button instead anywhere in the whole <iframe> element so one won't mis-click; will ignore small / narrow <iframe>s.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        <iframe> click to load
// @name:zh-CN 手动加载 <iframe>
// @description NOT lazyload; click a button instead anywhere in the whole <iframe> element so one won't mis-click; will ignore small / narrow <iframe>s.
// @description:zh-CN 不是 lazyload;点击按钮而不是点击 <iframe> 元素,以免误触;会忽略大小较小的 <iframe> 元素。
// @namespace   RainSlide
// @author      RainSlide
// @version     1.0
// @match       *://*/*
// @grant       none
// @inject-into context
// @run-at      document-end
// ==/UserScript==

document.querySelectorAll('iframe').forEach(
	iframe =>

		// attribute
		iframe.getAttribute("src")    !== null &&
		iframe.getAttribute("srcdoc") === null &&

		// content size
		iframe.clientWidth  >= 72 &&
		iframe.clientHeight >= 72 &&
		( iframe.clientWidth + iframe.clientHeight ) >= 256 &&

		iframe.setAttribute("srcdoc",

`<style>
html, body { height: 100%; }
body {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	box-sizing: border-box;
	min-width: 5em;
	margin: 0;
	padding: .5em;
	border: 2px dashed currentColor;
}
a {
	margin-bottom: 1ex;
	word-break: break-all;
	font-family: monospace;
}
</style>
<a href="${ iframe.src }" target="_blank" rel="noreferrer noopener">${ iframe.src }</a>
<button onclick="window.frameElement.removeAttribute('srcdoc')">${
	new Map([
		["en-US", "Load"],
		["zh-CN", "加载"],
		["zh-TW", "加載"],
		["zh-HK", "加載"]
	]).get( navigator.language ) || "Load"
}</button>`

		)

);