testing with google miscell project
A alert.js is include and the user.js should prevent it from running.
// ==UserScript== // @id 5008e85f-e821-414f-b82a-4fd4c76d5485 // @name testcase // @include http://www.cnblogs.com/* // @run-at document-start // ==/UserScript== document.addEventListener('beforescriptexecute', function(e){ if(e.target.src.indexOf('alert.js') != -1){ e.preventDefault(); document.removeEventListener(e.type,arguments.callee,0); } },false);
It does but not when it was open in a target = _blank link like below: