Fixed reset action (remove host from hosts list)
This commit is contained in:
parent
65206a34cd
commit
89b969bd6c
2 changed files with 34 additions and 3 deletions
33
lib/popup.js
33
lib/popup.js
|
@ -349,10 +349,28 @@
|
||||||
reset: function(e) {
|
reset: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Is allowed to reset?
|
||||||
|
if( popup.el.resetBtn.hasClass('pure-button-disabled') ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( confirm('Do you really want all away?') ) {
|
if( confirm('Do you really want all away?') ) {
|
||||||
|
// Remove stored data for current host
|
||||||
popup.storage.setMode(popup.storage.MODE.private);
|
popup.storage.setMode(popup.storage.MODE.private);
|
||||||
popup.storage.remove();
|
popup.storage.remove();
|
||||||
|
|
||||||
|
// Remove host from hosts inside global storage
|
||||||
|
popup.storage.setMode(popup.storage.MODE.global);
|
||||||
|
var oldHosts = popup.storage.get('hosts'),
|
||||||
|
newHosts = [];
|
||||||
|
oldHosts.forEach(function(host) {
|
||||||
|
if( host !== popup.protocol + '//' + popup.host ) {
|
||||||
|
newHosts.push(host);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popup.storage.set('hosts', newHosts);
|
||||||
|
|
||||||
|
// Remove customjs from frontend
|
||||||
chrome.tabs.sendRequest(popup.tabId, {method: "removeData", reload: false});
|
chrome.tabs.sendRequest(popup.tabId, {method: "removeData", reload: false});
|
||||||
popup.data = {
|
popup.data = {
|
||||||
config: {
|
config: {
|
||||||
|
@ -474,7 +492,20 @@
|
||||||
popup.el.draftRemoveLink.addClass('is-hidden');
|
popup.el.draftRemoveLink.addClass('is-hidden');
|
||||||
|
|
||||||
// Apply other host data
|
// Apply other host data
|
||||||
popup.applyData(hostData.data, true);
|
try {
|
||||||
|
popup.applyData(hostData.data, true);
|
||||||
|
}
|
||||||
|
// Hotfix for host without customjs
|
||||||
|
catch(err) {
|
||||||
|
popup.applyData({
|
||||||
|
config: {
|
||||||
|
enable: false,
|
||||||
|
include: '',
|
||||||
|
extra: ''
|
||||||
|
},
|
||||||
|
source: ''
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Start making drafts
|
// Start making drafts
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
|
|
||||||
"name": "Custom JavaScript for websites ",
|
"name": "Custom JavaScript for websites ",
|
||||||
|
"short_name": "customjs",
|
||||||
"description": "Run custom JavaScript on any website.",
|
"description": "Run custom JavaScript on any website.",
|
||||||
"version": "2.1.0",
|
"version": "2.1.1",
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"http://*/",
|
"http://*/",
|
||||||
|
@ -19,7 +20,6 @@
|
||||||
"content_security_policy": "script-src 'self' https://*.googleapis.com; object-src 'self'",
|
"content_security_policy": "script-src 'self' https://*.googleapis.com; object-src 'self'",
|
||||||
|
|
||||||
"content_scripts": [{
|
"content_scripts": [{
|
||||||
//"all_frames": true,
|
|
||||||
"matches": ["<all_urls>"],
|
"matches": ["<all_urls>"],
|
||||||
"js": ["lib/api.js"]
|
"js": ["lib/api.js"]
|
||||||
}, {
|
}, {
|
||||||
|
|
Reference in a new issue