JSFiddle - React, Tailwind, and code Playground

by zjcqoo

HTML

<script>
	// for chrome
	var raw_fn = Document.prototype.createElement;

	Document.prototype.createElement = function() {

		// 调用原生函数
		var element = raw_fn.apply(this, arguments);

		// 为脚本元素安装属性钩子
		if (element.tagName == 'SCRIPT') {
			element.__defineSetter__('src', function(url) {
				console.log('设置路径:', url);
			});
		}

		// 返回元素实例
		return element;
	};
</script>

<button id="btn">创建脚本</button>
<script>
	btn.onclick = function() {
		var el = document.createElement('script');
		el.src = 'http://www.etherdream.com/xss/out.js?dynamic';
		document.body.appendChild(el);
	};
</script>