diff --git a/.gitignore b/.gitignore index 92b2c45a1..b79a916f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +builds/ node_modules/ tmp/ diff --git a/4chan_x.meta.js b/4chan_x.meta.js index e0f534ab9..bb417e306 100644 --- a/4chan_x.meta.js +++ b/4chan_x.meta.js @@ -6,16 +6,16 @@ // @copyright 2009-2011 James Campos // @copyright 2012-2013 Nicolas Stepien // @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== diff --git a/4chan_x.user.js b/4chan_x.user.js index 1601cf1df..473ecd092 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -6,21 +6,21 @@ // @copyright 2009-2011 James Campos // @copyright 2012-2013 Nicolas Stepien // @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 @@ -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'); diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8bcc068df..42fa67ad2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. diff --git a/Gruntfile.js b/Gruntfile.js index ce7ec379c..f9b12b6e1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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']); diff --git a/lib/$.coffee b/lib/$.coffee index 8220b4d4e..f238701f6 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -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 -> diff --git a/package.json b/package.json index 23a7825b2..ad5deea45 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/manifest.json b/src/manifest.json new file mode 100644 index 000000000..f125f6cb5 --- /dev/null +++ b/src/manifest.json @@ -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" +} diff --git a/src/metadata.js b/src/metadata.js index 5f190df0f..415133169 100644 --- a/src/metadata.js +++ b/src/metadata.js @@ -6,16 +6,17 @@ // @copyright 2009-2011 James Campos // @copyright 2012-<%= grunt.template.today('yyyy') %> Nicolas Stepien // @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==