forked from OctoLinker/OctoLinker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Firefox support (OctoLinker#100)
* Do request in background * Repleace innerHTML with textContent * Tweak build step * Produce production build * Extend eslint ignore * Use background loading for all requests * Enable sourcemaps for dev build * Add `open-firefox` npm script This opens Firefox with the extension installed from ./firefox, using https://github.com/mozilla/web-ext Usage: npm run build-firefox npm run open-firefox * Use flag to determine if event handler is already attached Firefox doesn't support hasEventListeners therefore I implemented the flag.
- Loading branch information
1 parent
166abef
commit e033c45
Showing
17 changed files
with
142 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
./dist | ||
./chrome | ||
./firefox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,6 @@ | |
}, | ||
"globals": { | ||
"fixture": true, | ||
"chrome": true, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
node_modules | ||
npm-debug.log | ||
chrome/app.js | ||
|
||
dist/ | ||
|
||
chrome/* | ||
!chrome/manifest.json | ||
|
||
firefox/* | ||
!firefox/manifest.json |
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "OctoLinker", | ||
"version": "4.1.1", | ||
"manifest_version": 2, | ||
"author": "Stefan Buck", | ||
"description": "", | ||
"homepage_url": "https://github.com/OctoLinker/browser-extension/", | ||
"icons": { | ||
"128": "icon.png" | ||
}, | ||
"applications": { | ||
"gecko": { | ||
"id": "[email protected]" | ||
} | ||
}, | ||
"background": { | ||
"scripts": ["background.js"] | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": [ | ||
"https://github.com/*", | ||
"https://gist.github.com/*" | ||
], | ||
"js": ["app.js"], | ||
"css": ["style.css"], | ||
"run_at": "document_idle", | ||
"all_frames": false | ||
} | ||
], | ||
"permissions": [ | ||
"https://github.com/", | ||
"https://githublinker.herokuapp.com/" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import $ from 'jquery'; | ||
|
||
function loader(urls, cb) { | ||
const req = urls.shift(); | ||
const url = req.url || req; | ||
|
||
$.ajax({ | ||
method: req.method || 'HEAD', | ||
url, | ||
}).then(function (res) { | ||
cb(null, url, res); | ||
}).fail(function () { | ||
if (urls.length === 0) { | ||
return cb(new Error('Could not load any url')); | ||
} | ||
|
||
loader(urls, cb); | ||
}); | ||
} | ||
|
||
chrome.runtime.onMessage.addListener(({ urls }, sender) => { | ||
loader(urls, (err, url, res) => { | ||
chrome.tabs.sendMessage(sender.tab.id, { | ||
err, | ||
url, | ||
res, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const argv = require('yargs').argv; | ||
const webpackConfig = require('./webpack.config.js'); | ||
const CopyWebpackPlugin = require('copy-webpack-plugin'); | ||
|
||
const dist = argv.dist; | ||
|
||
const config = Object.assign({}, webpackConfig, { | ||
devtool: '', | ||
output: { | ||
path: `dist/${dist}`, | ||
filename: '[name].js', | ||
}, | ||
}); | ||
|
||
config.plugins.push( | ||
new CopyWebpackPlugin([ | ||
{ from: `${dist}/manifest.json` }, | ||
]) | ||
); | ||
|
||
module.exports = config; |