luciopaiva / witchcraft

Inject Javascript and CSS right from your file system. Think GreaseMonkey for more advanced users.
https://luciopaiva.com/witchcraft
MIT License
254 stars 18 forks source link

Issue with multiple js includes since v. 2.6 #25

Closed guulbanne closed 4 years ago

guulbanne commented 4 years ago

My scripts started failing since v. 2.6 of the extension so I did some digging and it seems to be linked to multiple includes in a single file.

in the console, the error is:

blank.html:1 Error in event handler: SyntaxError: Unexpected identifier at Function () at chrome-extension://hokcepcfcicnhalinladgknhaljndhpc/content-script.js:8:9

in the [insert domain here].js file: `// @include test1.js var someText = getSomething();

// @include test2.js

alert(hugify(someText));`

test1.js function getSomething(){ return 'Here goes something'; }

test2.js function hugify(text){ return text.toUpperCase(); }

I found I could sometimes work around it by nesting include statements e.g. including test2.js inside test1.js and including test1.js only in domainname.js

I did not test this in css, however.

luciopaiva commented 4 years ago

Hi @guulbanne,

There was a bug indeed, I was able to reproduce it here. It was a case not being covered by tests. It's fixed now in 2.6.1 and a unit test was added to prevent it from happening again.

It normally takes a few days until the Chrome store publishes a new version, but you can also clone latest master and load the extension manually if you're in a hurry.

Thanks for reporting the issue!

luciopaiva commented 4 years ago

P.S.: instead of cloning the repo, you can also directly download the extension zip here: https://github.com/luciopaiva/witchcraft/releases/tag/v2.6.1 Download the file witchcraft-v2.6.1.zip.

guulbanne commented 4 years ago

Excellent! It took a while before I could get back to this, but I can confirm: the new version arrived via Google and everything's now working as expected. Thank you!