-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.jsx
45 lines (40 loc) · 1.38 KB
/
popup.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//Run on open
'use strict';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
quickSubmitEnabled: false
};
this.handleChange = this.handleChange.bind(this);
}
componentDidMount() {
chrome.storage.sync.get(['quickSubmitEnabled'], function(result) {
if (result.enabled === undefined) {
chrome.storage.sync.set({ quickSubmitEnabled: false });
}
this.setState({
quickSubmitEnabled: result.quickSubmitEnabled
});
console.log('quickSub: ', this.state.quickSubmitEnabled);
chrome.storage.sync.set({quickSubmitEnabled: this.state.quickSubmitEnabled});
}.bind(this));
}
handleChange(e) {
this.setState({ quickSubmitEnabled: e.target.checked },
function(){
chrome.storage.sync.set({quickSubmitEnabled: this.state.quickSubmitEnabled});
});
}
render() {
return (
<div>
<h4 className="border border-dark bg-dark">Afficient Academy Enhancer v1.14</h4>
<input className="form-check-input" type="checkbox" id="quickSubmitDiv" onClick={this.handleChange} checked={this.state.quickSubmitEnabled}/>
<label class="form-check-label"> Press Shift+Enter to submit answers </label>
</div>
);
}
}
const popupContainer = document.querySelector('#container');
ReactDOM.render(<App />,popupContainer);