Make Chrome ext/userscript/userjs builds.

This commit is contained in:
Nicolas Stepien 2013-03-18 01:43:50 +01:00
parent f4c248f18c
commit 0a41f0ae6c
9 changed files with 71 additions and 28 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
builds/
node_modules/
tmp/

View File

@ -6,16 +6,16 @@
// @copyright 2009-2011 James Campos <james.r.campos@gmail.com>
// @copyright 2012-2013 Nicolas Stepien <stepien.nicolas@gmail.com>
// @license MIT; http://en.wikipedia.org/wiki/Mit_license
// @match *://api.4chan.org/*
// @match *://boards.4chan.org/*
// @match *://images.4chan.org/*
// @match *://sys.4chan.org/*
// @match *://api.4chan.org/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @grant GM_openInTab
// @run-at document-start
// @updateURL https://github.com/MayhemYDG/4chan-x/raw/v3/4chan_x.meta.js
// @downloadURL https://github.com/MayhemYDG/4chan-x/raw/v3/4chan_x.user.js
// @updateURL https://github.com/MayhemYDG/4chan-x/raw/v3/4chan-X.meta.js
// @downloadURL https://github.com/MayhemYDG/4chan-x/raw/v3/4chan-X.user.js
// @icon data:image/gif;base64,R0lGODlhEAAQAKECAAAAAGbMM////////yH5BAEKAAIALAAAAAAQABAAAAIxlI+pq+D9DAgUoFkPDlbs7lGiI2bSVnKglnJMOL6omczxVZK3dH/41AG6Lh7i6qUoAAA7
// ==/UserScript==

View File

@ -6,21 +6,21 @@
// @copyright 2009-2011 James Campos <james.r.campos@gmail.com>
// @copyright 2012-2013 Nicolas Stepien <stepien.nicolas@gmail.com>
// @license MIT; http://en.wikipedia.org/wiki/Mit_license
// @match *://api.4chan.org/*
// @match *://boards.4chan.org/*
// @match *://images.4chan.org/*
// @match *://sys.4chan.org/*
// @match *://api.4chan.org/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @grant GM_openInTab
// @run-at document-start
// @updateURL https://github.com/MayhemYDG/4chan-x/raw/v3/4chan_x.meta.js
// @downloadURL https://github.com/MayhemYDG/4chan-x/raw/v3/4chan_x.user.js
// @updateURL https://github.com/MayhemYDG/4chan-x/raw/v3/4chan-X.meta.js
// @downloadURL https://github.com/MayhemYDG/4chan-x/raw/v3/4chan-X.user.js
// @icon data:image/gif;base64,R0lGODlhEAAQAKECAAAAAGbMM////////yH5BAEKAAIALAAAAAAQABAAAAIxlI+pq+D9DAgUoFkPDlbs7lGiI2bSVnKglnJMOL6omczxVZK3dH/41AG6Lh7i6qUoAAA7
// ==/UserScript==
/* 4chan X Beta - Version 3.0.0 - 2013-03-15
/* 4chan X Beta - Version 3.0.0 - 2013-03-18
* http://mayhemydg.github.com/4chan-x/
*
* Copyright (c) 2009-2011 James Campos <james.r.campos@gmail.com>
@ -918,7 +918,7 @@
$.add(d.head, script);
return $.rm(script);
},
unsafeWindow: window.opera ? window : unsafeWindow !== window ? unsafeWindow : (function() {
unsafeWindow: window.opera ? window : typeof unsafeWindow !== "undefined" && unsafeWindow !== null ? unsafeWindow : (function() {
var p;
p = d.createElement('p');
p.setAttribute('onclick', 'return window');

View File

@ -38,7 +38,5 @@ Note: this is only used to release new 4chan X versions, and is **not** needed o
### Contribute
- Edit the CoffeeScript sources.
- Build the JavaScript.
- If the edits affect regular users, edit the changelog.
- Fork the repository.
- Open a pull request.

View File

@ -21,19 +21,37 @@ module.exports = function(grunt) {
],
dest: 'tmp/script.coffee'
},
script: {
manifest: {
options: { process: { data: pkg } },
src: 'src/manifest.json',
dest: 'builds/crx/manifest.json'
},
crx: {
options: { process: { data: pkg } },
src: [
'src/banner.js',
'tmp/script.js'
],
dest: 'builds/crx/script.js'
},
metadata: {
options: { process: { data: pkg } },
src: 'src/metadata.js',
dest: 'builds/<%= pkg.name %>.meta.js'
},
userscript: {
options: { process: { data: pkg } },
src: [
'src/metadata.js',
'src/banner.js',
'tmp/script.js'
],
dest: '<%= pkg.meta.files.userjs %>'
dest: 'builds/<%= pkg.name %>.user.js'
},
metadata: {
options: { process: { data: pkg } },
src: 'src/metadata.js',
dest: '<%= pkg.meta.files.metajs %>'
userjs: {
// Lazily copy the userscript
src: 'builds/<%= pkg.name %>.user.js',
dest: 'builds/<%= pkg.name %>.js'
}
},
coffee: {
@ -89,7 +107,16 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-exec');
grunt.registerTask('default', ['concat:coffee', 'coffee:script', 'concat:script', 'concat:metadata', 'clean']);
grunt.registerTask('default', [
'concat:coffee',
'coffee:script',
'concat:manifest',
'concat:crx',
'concat:userscript',
'concat:userjs',
'concat:metadata',
'clean'
]);
grunt.registerTask('release', ['default', 'exec:commit', 'exec:push']);
grunt.registerTask('patch', ['bump', 'updcl:3']);
grunt.registerTask('minor', ['bump:minor', 'updcl:2']);

View File

@ -189,7 +189,7 @@ $.extend $,
unsafeWindow:
if window.opera # Opera
window
else if unsafeWindow isnt window # Firefox
else if unsafeWindow? # Firefox
unsafeWindow
else # Chrome
do ->

View File

@ -7,10 +7,12 @@
"repo": "https://github.com/MayhemYDG/4chan-x/",
"page": "http://mayhemydg.github.com/4chan-x/",
"mainBranch": "v3",
"files": {
"metajs": "4chan_x.meta.js",
"userjs": "4chan_x.user.js"
}
"matches": [
"*://api.4chan.org/*",
"*://boards.4chan.org/*",
"*://images.4chan.org/*",
"*://sys.4chan.org/*"
]
},
"devDependencies": {
"grunt": "~0.4.0",

14
src/manifest.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "<%= meta.name %>",
"version": "<%= version %>",
"manifest_version": 2,
"description": "<%= description %>",
"content_scripts": [{
"js": ["script.js"],
"matches": <%= JSON.stringify(meta.matches) %>,
"run_at": "document_start"
}],
"homepage_url": "<%= meta.page %>",
"incognito": "spanning",
"minimum_chrome_version": "25"
}

View File

@ -6,16 +6,17 @@
// @copyright 2009-2011 James Campos <james.r.campos@gmail.com>
// @copyright 2012-<%= grunt.template.today('yyyy') %> Nicolas Stepien <stepien.nicolas@gmail.com>
// @license MIT; http://en.wikipedia.org/wiki/Mit_license
// @match *://boards.4chan.org/*
// @match *://images.4chan.org/*
// @match *://sys.4chan.org/*
// @match *://api.4chan.org/*
<%=
meta.matches.map(function(match) {
return '// @match ' + match;
}).join('\n')
%>
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @grant GM_openInTab
// @run-at document-start
// @updateURL <%= meta.repo %>raw/<%= meta.mainBranch %>/<%= meta.files.metajs %>
// @downloadURL <%= meta.repo %>raw/<%= meta.mainBranch %>/<%= meta.files.userjs %>
// @updateURL <%= meta.repo %>raw/<%= meta.mainBranch %>/<%= name %>.meta.js
// @downloadURL <%= meta.repo %>raw/<%= meta.mainBranch %>/<%= name %>.user.js
// @icon data:image/gif;base64,<%= grunt.file.read('img/icon.gif', {encoding: 'base64'}) %>
// ==/UserScript==