jerone / UserScripts

🐵 My UserScripts
https://github.com/jerone/UserScripts#readme
GNU General Public License v3.0
339 stars 39 forks source link

UTF8 byte-order-mark at beginning of files #135

Closed The-Compiler closed 6 years ago

The-Compiler commented 6 years ago

At least Github_Pull_Request_From.user.js (but probably others as well) does have a UTF-8 BOM.

This does violate what's documented in the Greasemonkey wiki:

Note that the opening // ==UserScript== and closing // ==/UserScript== must be precisely at the beginning of its line.

since the file starts with 0xEF, 0xBB, 0xBF before the // ==UserScript==.

This causes it to not work properly in qutebrowser. I'll fix this there as well (by stripping it), but it might affect other Greasemonkey implementations as well.

Assuming you're on Unix, you should be able to remove them all using:

$ find . -name '*.js' -exec sed -i $'1s/^\uFEFF//' {} \;

Alternatively (if your editor inserts them), I guess it'd be possible to move the // ==UserScript== line to the second line.

jerone commented 6 years ago

Hi @The-Compiler, all my userscripts are compatible with Tampermonkey, where the UTF-8 BOM appears no issue. But I'm happy to accept (most) PR to support other userscript clients.