Generate .meta.js for gdrive userscript for update checks

Tampermonkey automatically requests www/js/cytube-google-drive.meta.js
to check for updates.  Changed the userscript generator to write an
additional .meta.js file so that works instead of 404ing.
This commit is contained in:
Calvin Montgomery 2017-08-19 16:31:01 -07:00
parent 9f0444a962
commit 0885a619b9
3 changed files with 24 additions and 4 deletions

2
.gitignore vendored
View file

@ -14,3 +14,5 @@ google-drive-subtitles
lib/
integration-test-config.json
conf/*.toml
www/js/cytube-google-drive.user.js
www/js/cytube-google-drive.meta.js

View file

@ -8,12 +8,30 @@ var includes = process.argv.slice(3).map(function (include) {
var lines = String(fs.readFileSync(
path.resolve(__dirname, 'cytube-google-drive.user.js'))).split('\n');
var userscriptOutput = '';
var metaOutput = '';
lines.forEach(function (line) {
if (line.match(/\{INCLUDE_BLOCK\}/)) {
console.log(includes);
userscriptOutput += includes + '\n';
} else if (line.match(/\{SITENAME\}/)) {
console.log(line.replace(/\{SITENAME\}/, sitename));
line = line.replace(/\{SITENAME\}/, sitename) + '\n';
userscriptOutput += line;
metaOutput += line;
} else {
console.log(line);
if (line.match(/==\/?UserScript|@name|@version/)) {
metaOutput += line + '\n';
}
userscriptOutput += line + '\n';
}
});
fs.writeFileSync(
path.join(__dirname, '..', 'www', 'js', 'cytube-google-drive.user.js'),
userscriptOutput
);
fs.writeFileSync(
path.join(__dirname, '..', 'www', 'js', 'cytube-google-drive.meta.js'),
metaOutput
);

View file

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "3.47.1",
"version": "3.47.2",
"repository": {
"url": "http://github.com/calzoneman/sync"
},