Skip to content

Commit

Permalink
Adopt for Firefox.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderby committed Sep 18, 2017
1 parent 6a70bd7 commit 7b39e8e
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#-----------------------------------
build/*
build.zip
build-firefox/*
build-firefox.zip

#Node.js modules
#-----------------------------------
Expand Down
44 changes: 37 additions & 7 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = function (grunt) {
require('create-grunt-tasks')(grunt, function (create) {

//
// --- Release task ---

create.task('release')
.sub('clean', [
'build/'
Expand Down Expand Up @@ -41,11 +41,41 @@ module.exports = function (grunt) {
dest: 'build.zip',
compression: 'DEFLATE'
})
// Firefox
.sub('clean', 'build-firefox')
.sub('copy', {
expand: true,
cwd: 'build/',
src: '**/*.*',
dest: 'build-firefox/'
})
.sub('copy', {
expand: true,
cwd: 'src/',
src: 'manifest.json',
dest: 'build-firefox/',
options: {
process: (content) => {
const fs = require('fs');
const path = require('path');
const obj = JSON.parse(content);
const ff = fs.readFileSync('src/manifest_firefox.json');
const ext = JSON.parse(ff);
Object.assign(obj, ext);
return JSON.stringify(obj, null, 4);
}
}
})
.sub('zip', {
src: ['build-firefox/**/*.*'],
dest: 'build-firefox.zip',
compression: 'DEFLATE'
})
.sub('ext-reload');

//
// --- Debug tasks ---

create.task('debug')
.sub('debug-js')
.sub('debug-css')
Expand All @@ -70,9 +100,9 @@ module.exports = function (grunt) {
paths: ['src/']
}
});

// ---- Watch ----

create.task('debug-watch')
.sub('concurrent', {
tasks: ['debug-watch-js', 'debug-watch-css', 'debug-watch-other'],
Expand Down Expand Up @@ -100,7 +130,7 @@ module.exports = function (grunt) {
files: ['src/**/*.less'],
tasks: ['debug-css', 'ext-reload']
});

create.task('debug-watch-other')
.sub('watch', {
files: ['src/**/*.{json,html,png,svg,ttf}'],
Expand Down Expand Up @@ -147,7 +177,7 @@ module.exports = function (grunt) {
closeServer();
});
server.listen(8890);

// Close server if no listeners
setTimeout(function () {
grunt.log.writeln('Auto-reloader did not connect.');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"homepage": "https://github.com/alexanderby/darkreader",
"devDependencies": {
"create-grunt-tasks": "^0.7.1",
"create-grunt-tasks": "^0.8.0",
"grunt": "^0.4.5",
"grunt-concurrent": "^2.0.0",
"grunt-contrib-clean": "^0.6.0",
Expand Down
5 changes: 4 additions & 1 deletion src/background/config_management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
};
var REMOTE_TIMEOUT_MS = 10 * 1000;
var RELOAD_INTERVAL_MS = 15 * 60 * 1000;
export var DEBUG = chrome.runtime.id !== 'eimadpbcbfnmbkopoojfekhnkhdbieeh';
export var DEBUG = [
'eimadpbcbfnmbkopoojfekhnkhdbieeh',
'[email protected]'
].indexOf(chrome.runtime.id) < 0;
var DEBUG_LOCAL_CONFIGS = DEBUG;

/**
Expand Down
12 changes: 12 additions & 0 deletions src/background/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,18 @@ style && style.parentElement.removeChild(style);
* installed in system.
*/
protected getFontList(onReturned: (fonts: string[]) => void) {
if (typeof chrome.fontSettings !== 'function') {
// Todo: Remove it as soon as Firefox and Edge get support.
setTimeout(() => onReturned([
'serif',
'sans-serif',
'monospace',
'cursive',
'fantasy',
'system-ui'
]));
return;
}
chrome.fontSettings.getFontList((res) => {
// id or name?
var fonts = res.map((r) => r.fontId);
Expand Down
8 changes: 8 additions & 0 deletions src/manifest_firefox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"applications": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "54.0"
}
}
}
5 changes: 1 addition & 4 deletions src/popup/style/_variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
// Colors of modal
@color-modal-tint: fadeout(@color-back,30%);

// Font
@font-family: 'Segoe UI',sans-serif;

//---------------------------
// Dark Reader variables
//---------------------------
Expand All @@ -44,7 +41,7 @@
@color-description: #37abc8;
@color-header: #e96c4c;
@color-error: #db4245;
@font-family: 'Open Sans', 'Segoe UI', 'Helvetica Neue', sans-serif;
@font-family: 'Open Sans', 'Segoe UI', 'Helvetica Neue', 'Ubuntu', sans-serif;
@size-control-inner: 2em;
@size-control-description: 0.875em;
@size-border: 0.1875em;
Expand Down
2 changes: 1 addition & 1 deletion src/popup/ui/site_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
// Add new site
this.sites.push(value);
textBox.text = '';
textBox.focus();
this.focus();
}
}
else {
Expand Down

0 comments on commit 7b39e8e

Please sign in to comment.