version 0.2.0

This commit is contained in:
Ray Lothian 2018-04-10 12:20:58 +04:30
parent 6cdf075737
commit 1213fff7b3
11 changed files with 339 additions and 205 deletions

View file

@ -3,12 +3,11 @@
<head>
<title>My Test Extension Options</title>
<style>
body { padding: 10px; }
textarea { width: 100%; }
#custom {
white-space: nowrap;
overflow: auto;
body {
min-width: 400px;
padding: 10px;
}
textarea { width: 100%; }
</style>
</head>
@ -16,7 +15,7 @@
<table width=100%>
<tr>
<td>
<label><input type="radio" name="mode" value="blacklist" id="mode-blacklist"> Black-list mode: Apply user-agent string to all tabs except the tabs with the following top-level hostnames (comma separated list of hostnames)</label>
<label><input type="radio" name="mode" value="blacklist" id="mode-blacklist"> Black-list mode: Apply the custom user-agent string to all tabs except the tabs with the following top-level hostnames (comma-separated list of hostnames)</label>
</td>
</tr>
<tr>
@ -24,7 +23,7 @@
</tr>
<tr>
<td>
<label><input type="radio" name="mode" value="whitelist" id="mode-whitelist"> White-list mode: Only apply user-agent string to the tabs with following top-level hostnames</label>
<label><input type="radio" name="mode" value="whitelist" id="mode-whitelist"> White-list mode: Only apply the custom user-agent string to the tabs with following top-level hostnames</label>
</td>
</tr>
<tr>
@ -32,11 +31,11 @@
</tr>
<tr>
<td>
<label><input type="radio" name="mode" value="custom" id="mode-custom"> Custom mode: Only apply user-agent string to the tabs with a matching top-level hostnames.</label> <a href="#" id="sample">Insert</a> a sample.
<label><input type="radio" name="mode" value="custom" id="mode-custom"> Custom mode: Try to resolve the user-agent string from the bellow JSON object; otherwise either use the default user-agent string or use the one that user is set from the popup.</label> <a href="#" id="sample">Insert</a> a sample JSON object.
</td>
</tr>
<tr>
<td><textarea id="custom" rows="5"></textarea></td>
<td><textarea id="custom" rows="5" wrap="off"></textarea></td>
</tr>
<tr>
<td><label><input type="checkbox" id="faqs"> Open FAQs page on updates</label></td>
@ -44,6 +43,7 @@
</table>
<p>
<button id="donate">Support Development</button>
<button id="reset">Reset</button>
<button id="save">Save</button>
<span id="status"></span>
</p>

View file

@ -54,7 +54,9 @@ function restore() {
document.addEventListener('DOMContentLoaded', restore);
document.getElementById('save').addEventListener('click', save);
document.getElementById('sample').addEventListener('click', () => {
document.getElementById('sample').addEventListener('click', e => {
e.preventDefault();
document.getElementById('custom').value = JSON.stringify({
'www.google.com': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36',
'www.bing.com': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0'
@ -63,6 +65,19 @@ document.getElementById('sample').addEventListener('click', () => {
document.getElementById('donate').addEventListener('click', () => {
chrome.tabs.create({
url: 'https://www.paypal.me/addondonation/10usd'
url: chrome.runtime.getManifest().homepage_url + '?rd=donate'
});
});
document.getElementById('reset').addEventListener('click', e => {
if (e.detail === 1) {
notify('Double-click to reset!');
}
else {
localStorage.clear();
chrome.storage.local.clear(() => {
chrome.runtime.reload();
window.close();
});
}
});