<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.

05.10.2020 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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>`

		)

);