diff --git a/controllers/scriptStorage.js b/controllers/scriptStorage.js index 2044be3ee..0a2efb031 100644 --- a/controllers/scriptStorage.js +++ b/controllers/scriptStorage.js @@ -227,11 +227,12 @@ exports.getMeta = function (aChunks, aCallback) { var str = ''; var i = 0; var len = aChunks.length; + var header = null; for (; i < aChunks.length; ++i) { - var header = null; + header = null; str += aChunks[i]; - header = /^\/\/ ==UserScript==([\s\S]*?)^\/\/ ==\/UserScript==/m.exec(str); + header = /^(?:\uFEFF)?\/\/ ==UserScript==([\s\S]*?)^\/\/ ==\/UserScript==/m.exec(str); if (header && header[1]) { return aCallback(parseMeta(header[1], true)); } } diff --git a/controllers/user.js b/controllers/user.js index 3925ba28e..d14c84503 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -925,7 +925,7 @@ exports.userGitHubImportScriptPage = function (aReq, aRes, aNext) { if (options.javascriptBlob.isUserJS) { // - var userscriptHeaderRegex = /^\/\/ ==UserScript==([\s\S]*?)^\/\/ ==\/UserScript==/m; + var userscriptHeaderRegex = /^(?:\uFEFF)?\/\/ ==UserScript==([\s\S]*?)^\/\/ ==\/UserScript==/m; var m = userscriptHeaderRegex.exec(aBlobUtf8); if (m && m[1]) { var userscriptMeta = scriptStorage.parseMeta(m[1], true);