mirror of
https://github.com/zhigang1992/AlwaysHTTPS.git
synced 2026-01-12 16:14:10 +08:00
Initial Commit
This commit is contained in:
24
.editorconfig
Normal file
24
.editorconfig
Normal file
@@ -0,0 +1,24 @@
|
||||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles between different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
|
||||
[*]
|
||||
|
||||
# Change these settings to your own preference
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.json]
|
||||
indent_size = 2
|
||||
|
||||
# We recommend you to keep these unchanged
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* text=auto
|
||||
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
node_modules
|
||||
temp
|
||||
.tmp
|
||||
dist
|
||||
.sass-cache
|
||||
app/bower_components
|
||||
test/bower_components
|
||||
package
|
||||
app/scripts
|
||||
|
||||
3
.yo-rc.json
Normal file
3
.yo-rc.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"generator-mocha": {}
|
||||
}
|
||||
10
app/_locales/en/messages.json
Normal file
10
app/_locales/en/messages.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"appName": {
|
||||
"message": "alwaysHTTPs",
|
||||
"description": "The name of the application"
|
||||
},
|
||||
"appDescription": {
|
||||
"message": "Always use HTTPS",
|
||||
"description": "The description of the application"
|
||||
}
|
||||
}
|
||||
BIN
app/images/icon-128.png
Normal file
BIN
app/images/icon-128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
BIN
app/images/icon-16.png
Normal file
BIN
app/images/icon-16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 758 B |
35
app/manifest.json
Normal file
35
app/manifest.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "__MSG_appName__",
|
||||
"version": "0.0.1",
|
||||
"manifest_version": 2,
|
||||
"description": "__MSG_appDescription__",
|
||||
"icons": {
|
||||
"16": "images/icon-16.png",
|
||||
"128": "images/icon-128.png"
|
||||
},
|
||||
"default_locale": "en",
|
||||
"background": {
|
||||
"scripts": [
|
||||
"scripts/chromereload.js",
|
||||
"scripts/background.js"
|
||||
]
|
||||
},
|
||||
"permissions": [
|
||||
"tabs",
|
||||
"http://*/*",
|
||||
"https://*/*"
|
||||
],
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": [
|
||||
"http://*/*",
|
||||
"https://*/*"
|
||||
],
|
||||
"js": [
|
||||
"scripts/contentscript.js"
|
||||
],
|
||||
"run_at": "document_end",
|
||||
"all_frames": false
|
||||
}
|
||||
]
|
||||
}
|
||||
7
app/scripts.babel/background.js
Normal file
7
app/scripts.babel/background.js
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
chrome.runtime.onInstalled.addListener(details => {
|
||||
console.log('previousVersion', details.previousVersion);
|
||||
});
|
||||
|
||||
console.log('\'Allo \'Allo! Event Page');
|
||||
23
app/scripts.babel/chromereload.js
Normal file
23
app/scripts.babel/chromereload.js
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
// Reload client for Chrome Apps & Extensions.
|
||||
// The reload client has a compatibility with livereload.
|
||||
// WARNING: only supports reload command.
|
||||
|
||||
const LIVERELOAD_HOST = 'localhost:';
|
||||
const LIVERELOAD_PORT = 35729;
|
||||
const connection = new WebSocket('ws://' + LIVERELOAD_HOST + LIVERELOAD_PORT + '/livereload');
|
||||
|
||||
connection.onerror = error => {
|
||||
console.log('reload connection got error:', error);
|
||||
};
|
||||
|
||||
connection.onmessage = e => {
|
||||
if (e.data) {
|
||||
const data = JSON.parse(e.data);
|
||||
if (data && data.command === 'reload') {
|
||||
chrome.runtime.reload();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
3
app/scripts.babel/contentscript.js
Normal file
3
app/scripts.babel/contentscript.js
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
console.log('\'Allo \'Allo! Content script');
|
||||
10
bower.json
Normal file
10
bower.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "alwayshttps",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
"mocha": "^2.5.3"
|
||||
}
|
||||
}
|
||||
135
gulpfile.babel.js
Normal file
135
gulpfile.babel.js
Normal file
@@ -0,0 +1,135 @@
|
||||
// generated on 2016-06-02 using generator-chrome-extension 0.5.6
|
||||
import gulp from 'gulp';
|
||||
import gulpLoadPlugins from 'gulp-load-plugins';
|
||||
import del from 'del';
|
||||
import runSequence from 'run-sequence';
|
||||
import {stream as wiredep} from 'wiredep';
|
||||
|
||||
const $ = gulpLoadPlugins();
|
||||
|
||||
gulp.task('extras', () => {
|
||||
return gulp.src([
|
||||
'app/*.*',
|
||||
'app/_locales/**',
|
||||
'!app/scripts.babel',
|
||||
'!app/*.json',
|
||||
'!app/*.html',
|
||||
], {
|
||||
base: 'app',
|
||||
dot: true
|
||||
}).pipe(gulp.dest('dist'));
|
||||
});
|
||||
|
||||
function lint(files, options) {
|
||||
return () => {
|
||||
return gulp.src(files)
|
||||
.pipe($.eslint(options))
|
||||
.pipe($.eslint.format());
|
||||
};
|
||||
}
|
||||
|
||||
gulp.task('lint', lint('app/scripts.babel/**/*.js', {
|
||||
env: {
|
||||
es6: true
|
||||
}
|
||||
}));
|
||||
|
||||
gulp.task('images', () => {
|
||||
return gulp.src('app/images/**/*')
|
||||
.pipe($.if($.if.isFile, $.cache($.imagemin({
|
||||
progressive: true,
|
||||
interlaced: true,
|
||||
// don't remove IDs from SVGs, they are often used
|
||||
// as hooks for embedding and styling
|
||||
svgoPlugins: [{cleanupIDs: false}]
|
||||
}))
|
||||
.on('error', function (err) {
|
||||
console.log(err);
|
||||
this.end();
|
||||
})))
|
||||
.pipe(gulp.dest('dist/images'));
|
||||
});
|
||||
|
||||
gulp.task('html', () => {
|
||||
return gulp.src('app/*.html')
|
||||
.pipe($.useref({searchPath: ['.tmp', 'app', '.']}))
|
||||
.pipe($.sourcemaps.init())
|
||||
.pipe($.if('*.js', $.uglify()))
|
||||
.pipe($.if('*.css', $.cleanCss({compatibility: '*'})))
|
||||
.pipe($.sourcemaps.write())
|
||||
.pipe($.if('*.html', $.htmlmin({removeComments: true, collapseWhitespace: true})))
|
||||
.pipe(gulp.dest('dist'));
|
||||
});
|
||||
|
||||
gulp.task('chromeManifest', () => {
|
||||
return gulp.src('app/manifest.json')
|
||||
.pipe($.chromeManifest({
|
||||
buildnumber: true,
|
||||
background: {
|
||||
target: 'scripts/background.js',
|
||||
exclude: [
|
||||
'scripts/chromereload.js'
|
||||
]
|
||||
}
|
||||
}))
|
||||
.pipe($.if('*.css', $.cleanCss({compatibility: '*'})))
|
||||
.pipe($.if('*.js', $.sourcemaps.init()))
|
||||
.pipe($.if('*.js', $.uglify()))
|
||||
.pipe($.if('*.js', $.sourcemaps.write('.')))
|
||||
.pipe(gulp.dest('dist'));
|
||||
});
|
||||
|
||||
gulp.task('babel', () => {
|
||||
return gulp.src('app/scripts.babel/**/*.js')
|
||||
.pipe($.babel({
|
||||
presets: ['es2015']
|
||||
}))
|
||||
.pipe(gulp.dest('app/scripts'));
|
||||
});
|
||||
|
||||
gulp.task('clean', del.bind(null, ['.tmp', 'dist']));
|
||||
|
||||
gulp.task('watch', ['lint', 'babel', 'html'], () => {
|
||||
$.livereload.listen();
|
||||
|
||||
gulp.watch([
|
||||
'app/*.html',
|
||||
'app/scripts/**/*.js',
|
||||
'app/images/**/*',
|
||||
'app/styles/**/*',
|
||||
'app/_locales/**/*.json'
|
||||
]).on('change', $.livereload.reload);
|
||||
|
||||
gulp.watch('app/scripts.babel/**/*.js', ['lint', 'babel']);
|
||||
gulp.watch('bower.json', ['wiredep']);
|
||||
});
|
||||
|
||||
gulp.task('size', () => {
|
||||
return gulp.src('dist/**/*').pipe($.size({title: 'build', gzip: true}));
|
||||
});
|
||||
|
||||
gulp.task('wiredep', () => {
|
||||
gulp.src('app/*.html')
|
||||
.pipe(wiredep({
|
||||
ignorePath: /^(\.\.\/)*\.\./
|
||||
}))
|
||||
.pipe(gulp.dest('app'));
|
||||
});
|
||||
|
||||
gulp.task('package', function () {
|
||||
var manifest = require('./dist/manifest.json');
|
||||
return gulp.src('dist/**')
|
||||
.pipe($.zip('alwaysHTTPs-' + manifest.version + '.zip'))
|
||||
.pipe(gulp.dest('package'));
|
||||
});
|
||||
|
||||
gulp.task('build', (cb) => {
|
||||
runSequence(
|
||||
'lint', 'babel', 'chromeManifest',
|
||||
['html', 'images', 'extras'],
|
||||
'size', cb);
|
||||
});
|
||||
|
||||
gulp.task('default', ['clean'], cb => {
|
||||
runSequence('build', cb);
|
||||
});
|
||||
47
package.json
Normal file
47
package.json
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "alwayshttps",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.7.2",
|
||||
"babel-preset-es2015": "^6.6.0",
|
||||
"del": "^2.2.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-babel": "^6.1.2",
|
||||
"gulp-cache": "^0.4.3",
|
||||
"gulp-chrome-manifest": "0.0.13",
|
||||
"gulp-clean-css": "^2.0.3",
|
||||
"gulp-eslint": "^2.0.0",
|
||||
"gulp-if": "^2.0.0",
|
||||
"gulp-imagemin": "^2.4.0",
|
||||
"gulp-livereload": "^3.8.1",
|
||||
"gulp-load-plugins": "^1.2.0",
|
||||
"gulp-htmlmin": "^1.3.0",
|
||||
"gulp-size": "^2.1.0",
|
||||
"gulp-sourcemaps": "^1.6.0",
|
||||
"gulp-uglify": "^1.5.3",
|
||||
"gulp-useref": "^3.0.8",
|
||||
"gulp-zip": "^3.2.0",
|
||||
"main-bower-files": "^2.11.1",
|
||||
"run-sequence": "^1.1.5",
|
||||
"wiredep": "^4.0.0"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"env": {
|
||||
"node": true,
|
||||
"browser": true
|
||||
},
|
||||
"globals": {
|
||||
"chrome": true
|
||||
},
|
||||
"rules": {
|
||||
"eol-last": 0,
|
||||
"quotes": [
|
||||
2,
|
||||
"single"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
29
test/index.html
Normal file
29
test/index.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Mocha Spec Runner</title>
|
||||
<link rel="stylesheet" href="../bower_components/mocha/mocha.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="../bower_components/mocha/mocha.js"></script>
|
||||
<script>mocha.setup('bdd');</script>
|
||||
<script src="../bower_components/chai/chai.js"></script>
|
||||
<script>
|
||||
var assert = chai.assert;
|
||||
var expect = chai.expect;
|
||||
var should = chai.should();
|
||||
</script>
|
||||
<!-- bower:js -->
|
||||
<!-- endbower -->
|
||||
<!-- include source files here... -->
|
||||
<!-- include spec files here... -->
|
||||
<script src="spec/test.js"></script>
|
||||
<script>
|
||||
if (navigator.userAgent.indexOf('PhantomJS') === -1) {
|
||||
mocha.run();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
11
test/spec/test.js
Normal file
11
test/spec/test.js
Normal file
@@ -0,0 +1,11 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
describe('Give it some context', function () {
|
||||
describe('maybe a bit more context here', function () {
|
||||
it('should run here few assertions', function () {
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user