How can I disable javascript popups/alerts in Chrome?

The only way to disable the alert boxes is to install either an extension or a userscript. The userscript you linked is for Firefox Greasemonkey and will not work on Chrome.

Additionally, the misbehaving page you cite is sneaky and runs that "word validator" in an iframe with code that fires the alert() immediately upon iframe reload.

But here's a userscript that defeats it:

// ==UserScript==
// @name        Wordswithfriends, Block javascript alerts
// @match       http://wordswithfriends.net/*
// @run-at      document-start
// ==/UserScript==

addJS_Node (null, null, overrideSelectNativeJS_Functions);

function overrideSelectNativeJS_Functions () {
    window.alert = function alert (message) {
        console.log (message);
    }
}

function addJS_Node (text, s_URL, funcToRun) {
    var D                                   = document;
    var scriptNode                          = D.createElement ('script');
    scriptNode.type                         = "text/javascript";
    if (text)       scriptNode.textContent  = text;
    if (s_URL)      scriptNode.src          = s_URL;
    if (funcToRun)  scriptNode.textContent  = '(' + funcToRun.toString() + ')()';

    var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
    targ.appendChild (scriptNode);
}

If you really want to disable ALL alerts() on ALL pages (Not recommended), then delete the // @match line.


There is at least one extension for that in the Chrome Web Store. Works for me, even though it sounds a bit suspect that it has an optional support by ads mode you can disable in its settings page. (I didn't find the setting, but figured it couldn't hurt null routing api.s13.us.)