I'm writing an extension for this site. In my injected script(injected using chrome.tabs.executeScript
) which runs at "document_end" everything seems to be working fine but I want to remove site's "alert" prompts.
To do I've placed this code in the injected script but it does not work:
window.alert = function(msg){
console.log("bypassed");
}
Also tried this from the injected script:
$('<script>window.alert = function (msg){}</' + 'script>').appendTo(document.body);
I've even tried this in the background page but this too doesn't:
chrome.tabs.executeScript({
code: 'window.alert=function(msg){}' //while alert("hello") works
});
What am I missing? I've written another extension for another site and this method does override the alert
function.
UPDATE: I'm unable to call native functions in the downloaded web page from the injected script which will happen when called from content script. But my injected script is loaded using chrome.tabs.executeScript