Closed McBen closed 3 years ago
maybe use some regex instead of manual parsing?
like
var regexHeader = /==UserScript==\s*([\s\S]*)\/\/\s*==\/UserScript==/m // Note: \s\S to match linebreaks
var regexEntry = /\/\/\s*@(\S+)\s+(.*)$/gm // example match: "\\ @name some text"
var header = regexHeader.exec(pluginCode);
if (header === null) return;
header = header[1]
var entry = regexEntry.exec(header);
while (entry) {
console.log(entry[1], " = ", entry[2]); // FIXME: entry[2] should be trimmed and " removed
entry = regexEntry.exec(header);
}
https://github.com/IITC-CE/IITC-Button/blob/d8b5d8be1c1314fbfcfa712727989114cae41f0d/src/helpers.js#L26
will fail if line is empty
like:
/edit additional: a missing space between // and @ is also accepted by tampermonkey but not by iitc-button
//@author sdfsdf