4chan-x/src/meta/metadata.js
2016-04-09 21:35:21 -07:00

47 lines
1.6 KiB
JavaScript

// ==UserScript==
// @name <%= meta.name %><%= meta.namesuffix[channel] %>
// @version <%= meta.version %>
// @minGMVer <%= meta.min.greasemonkey %>
// @minFFVer <%= meta.min.firefox %>
// @namespace <%= name %>
// @description <%= description %>
// @license MIT; <%= meta.license %>
<%=
(function() {
function expand(items, regex, substitutions) {
var results = [];
items.forEach(function(item) {
if (regex.test(item)) {
substitutions.forEach(function(s) {
results.push(item.replace(regex, s));
});
} else {
results.push(item);
}
});
return results;
}
function expandMatches(matches) {
return expand(matches, /^\*/, ['http', 'https']);
}
return [].concat(
expandMatches(meta.matches).map(function(match) {
return '// @include ' + match;
}),
expandMatches(meta.exclude_matches).map(function(match) {
return '// @exclude ' + match;
})
).join('\n');
})()
%>
<%=
meta.grants.map(function(grant) {
return '// @grant ' + grant;
}).join('\n')
%>
// @run-at document-start
// @updateURL <%= (channel !== 'noupdate') ? (meta.downloads + name + meta.suffix[channel] + '.meta.js') : 'https://noupdate.invalid/' %>
// @downloadURL <%= (channel !== 'noupdate') ? (meta.downloads + name + meta.suffix[channel] + '.user.js') : 'https://noupdate.invalid/' %>
// @icon data:image/png;base64,<%= grunt.file.read('src/meta/icon48.png', {encoding: 'base64'}) %>
// ==/UserScript==