JSFiddle - React, Tailwind, and code Playground
JavaScript
// 保存上级接口
var raw_fn = Element.prototype.setAttribute;
// 勾住当前接口
Element.prototype.setAttribute = function(name, value) {
// 额外细节实现
if (this.tagName == 'SCRIPT' && /^src$/i.test(name)) {
if (/xss/.test(value)) {
if (confirm('试图加载可疑模块:\n\n' + value + '\n\n是否拦截?')) {
return;
}
}
}
raw_fn.apply(this, arguments);
};
// 创建脚本
var el = document.createElement('script');
//el.setAttribute('SRC', 'http://www.etherdream.com/xss/alert.js');
el.src="http://www.etherdream.com/xss/alert.js"
document.body.appendChild(el);