假期后的开张贴
import win.ui;
/*DSG{{*/
var winform = win.form(text="Edge链接拦截";right=759;bottom=469)
winform.add(
wb={cls="custom";left=10;top=10;right=749;bottom=459;edge=1;transparent=1;z=1}
)
/*}}*/
import web.view;
wb = web.view(winform.wb);
wb.external = {
postMessage = function(msg){
var data = web.json.parse(msg);
if(data.type == 'linkClicked'){
wb.location = data.url;
}
}
}
wb.preloadScript(`document.addEventListener('click', function(e) {
var target = e.target;
while(target && target.tagName !== 'A') {
target = target.parentElement;
}
if(target && target.tagName === 'A') {
e.preventDefault();
aardio.postMessage(JSON.stringify({
type: 'linkClicked',
url: target.href
}));
}
}, true);
window.open = function(url){window.location.href = url;}
`)
wb.go("https://www.taobao.com");
winform.show();
win.loopMessage();