Skip to content

Commit

Permalink
Merge pull request #103 from adambriny/bugfix/firefox
Browse files Browse the repository at this point in the history
Fixed firefox support, added popup menu
  • Loading branch information
berzniz authored Apr 10, 2020
2 parents 793bdec + 445fc8e commit 101b09f
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 20 deletions.
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"react-treeview": "^0.4.7",
"source-map-support": "^0.4.15",
"style-loader": "^0.23.1",
"webext-domain-permission-toggle": "^0.1.0",
"webext-domain-permission-toggle": "^1.0.0",
"webext-dynamic-content-scripts": "^6.0.3",
"webpack": "^4.28.1",
"webpack-dev-server": "^3.1.14",
"write-file-webpack-plugin": "^4.5.0"
Expand All @@ -48,13 +49,14 @@
"sanitize-html": "^1.20.0",
"snazzy": "^7.0.0",
"standard": "^12.0.1",
"webext-dynamic-content-scripts": "^6.0.3",
"webstore-upload": "^0.0.8"
},
"standard": {
"env": [
"jest"
],
"globals": [ "browser" ]
"globals": [
"browser"
]
}
}
4 changes: 2 additions & 2 deletions src/js/background.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'webext-dynamic-content-scripts'
import { addContextMenu } from 'webext-domain-permission-toggle'
import addDomainPermissionToggle from 'webext-domain-permission-toggle'

addContextMenu()
addDomainPermissionToggle()
12 changes: 9 additions & 3 deletions src/js/components/options/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from 'react'
import { StorageSync } from '../../lib'
import BodyColor from '../bodyColor'

const url = 'https://chrome.google.com/webstore/detail/github-pull-request-tree/nfhdjopbhlggibjlimhdbogflgmbiahc'
const chromeStoreUrl = 'https://chrome.google.com/webstore/detail/github-pull-request-tree/nfhdjopbhlggibjlimhdbogflgmbiahc'
const firefoxStoreUrl = 'https://addons.mozilla.org/en-US/firefox/addon/better-pull-request-for-github/'

class Options extends React.Component {
constructor (props) {
Expand All @@ -20,17 +21,22 @@ class Options extends React.Component {
this.setState(await StorageSync.get())
}

isChrome() {
return typeof browser === "undefined"
}

render () {
return (
<div className='container'>
<BodyColor isDark={this.state.darkMode} />
<div className='text-center'>
<h1>Better Pull Request</h1>
<p>
Thanks for using Better Pull Request Chrome Extension! 🎉
Thanks for using Better Pull Request {this.isChrome() ? "Chrome" : "Firefox"} Extension! 🎉
</p>
<p>
If you're enjoying this extension, please <a href={url}>rate it on the Chrome Store</a>.
If you're enjoying this extension, please <a href={this.isChrome() ? chromeStoreUrl : firefoxStoreUrl} target="_blank">rate it
on the {this.isChrome() ? "Chrome" : "Firefox"} Store</a>.
</p>
</div>
<div>
Expand Down
9 changes: 4 additions & 5 deletions src/js/components/tree/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,11 @@ class Tree extends React.Component {
}

onOptions () {
const { runtime } = (window.chrome || browser)
if (runtime.openOptionsPage) {
runtime.openOptionsPage()
} else {
window.open(runtime.getURL('options.html'))
let browserApi = window.chrome
if (typeof browser !== "undefined") {
browserApi = browser
}
window.open(browserApi.runtime.getURL('options.html'))
}

onClose () {
Expand Down
3 changes: 3 additions & 0 deletions src/manifest.chrome.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"css": []
}
],
"browser_action": {
"default_popup": "options.html"
},
"options_page": "options.html",
"web_accessible_resources": ["options.html"],
"icons": {
Expand Down
13 changes: 11 additions & 2 deletions src/manifest.firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"permissions": [
"contextMenus",
"storage",
"activeTab",
"*://*.github.com/*"
],
"optional_permissions": [
Expand All @@ -13,8 +14,7 @@
"background": {
"scripts": [
"background.js"
],
"persistent": false
]
},
"content_scripts": [
{
Expand All @@ -28,7 +28,16 @@
"css": []
}
],
"browser_action": {
"default_icon": {
"16": "16x16.png",
"48": "48x48.png",
"128": "128x128.png"
},
"default_popup": "options.html"
},
"options_ui": {
"chrome_style": true,
"page": "options.html"
},
"web_accessible_resources": ["options.html"],
Expand Down
3 changes: 2 additions & 1 deletion src/pages/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ body {

.container {
margin-top: 50px;
width: 500px;
padding: 0 30px 20px 30px;
width: 550px;
}

.text-center {
Expand Down
10 changes: 6 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8265,10 +8265,12 @@ webext-additional-permissions@^0.1.0:
dependencies:
"@types/chrome" "0.0.86"

webext-domain-permission-toggle@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/webext-domain-permission-toggle/-/webext-domain-permission-toggle-0.1.0.tgz#82c0f611a075958e5b879fd77f69908236615607"
integrity sha512-zPwVKYa5EiH0htXedmoAWUaMqU7pOr+4dlzFyGVM64Q0jLVo3V8AVcYOVDKtY+c9qOkhtoSUCGcXCnbs5u8eNg==
webext-domain-permission-toggle@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/webext-domain-permission-toggle/-/webext-domain-permission-toggle-1.0.0.tgz#6f9a6d3234ffe596921d1be5ae8823ef5b02ebd2"
integrity sha512-K6RAOYtVCMAmqjQPopMbGOIoxpFU05ERGgaLkUNvFCdpPsXLB5y4m1+Cq1dezyfx6FU0lLEqxoL/5/49+EY5zA==
dependencies:
webext-additional-permissions "^0.1.0"

webext-dynamic-content-scripts@^6.0.3:
version "6.0.3"
Expand Down

0 comments on commit 101b09f

Please sign in to comment.