Search code examples
javascriptchromiumuserscripts

"Uncaught SyntaxError: Unexpected token (" but there is no error


I'm authoring a simple userscript that will give the backspace button navigation control like in windows (specifically this is for linux users) for Chromium browser.

This script was working, then I made a few alterations to it (very simple stuff, commenting, tabbing, making it pretty), and now i'm getting this error:

Uncaught SyntaxError: Unexpected token (

on this line

document.head.appendChild(script);

The script is located here - i'm pulling out my hair trying to figure this out.

The script really only applies to chromium as ff gives you a configuration option to enable this functionality.. - Chromium 15.0.874.106 (Developer Build 107270) Ubuntu 11.10

Edit if someone can tell me why this doesn't work that would be great

EmbedCodeOnPage("(function() {" + fn.toString() + "})();"); // fails
EmbedCodeOnPage("(" + fn.toString() + ")()"); // works.

Solution

  • because you are just dropping in an anonymous function and not executing it

    change line 46 and add ()