Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sorry if it's been asked. I've already found several solutions that aren't working. Not sure what I'm doing wrong.

I don't want to disable all javascript, only Javascript alert boxes. The ones that pop up and force you to click OK or X to close them.

I've found user scripts that claim to do this (example: ). I've put chrome on the dev channel, start chrome with the --enable-user-scripts switch, the script shows up as installed.

But I still get the alert boxes.

An example alert box that isn't getting disabled is at - put in any garbage word into the word validator on the right sidebar. You get a popup telling you it's not a word.

share|improve this question
up vote 6 down vote accepted

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*
// @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.

share|improve this answer
I accepted this answer so hard my mouse exploded. Works like a charm. Thank you very much ^^ – CreeDorofl Jul 31 '12 at 17:16
You're welcome! Glad to help. – Brock Adams Jul 31 '12 at 18:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .