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) {
|
||||
e.preventDefault();
|
||||
|
||||
// Is allowed to reset?
|
||||
if( popup.el.resetBtn.hasClass('pure-button-disabled') ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( confirm('Do you really want all away?') ) {
|
||||
// Remove stored data for current host
|
||||
popup.storage.setMode(popup.storage.MODE.private);
|
||||
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});
|
||||
popup.data = {
|
||||
config: {
|
||||
|
@ -474,7 +492,20 @@
|
|||
popup.el.draftRemoveLink.addClass('is-hidden');
|
||||
|
||||
// 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 {
|
||||
// Start making drafts
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
"manifest_version": 2,
|
||||
|
||||
"name": "Custom JavaScript for websites ",
|
||||
"short_name": "customjs",
|
||||
"description": "Run custom JavaScript on any website.",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
|
||||
"permissions": [
|
||||
"http://*/",
|
||||
|
@ -19,7 +20,6 @@
|
|||
"content_security_policy": "script-src 'self' https://*.googleapis.com; object-src 'self'",
|
||||
|
||||
"content_scripts": [{
|
||||
//"all_frames": true,
|
||||
"matches": ["<all_urls>"],
|
||||
"js": ["lib/api.js"]
|
||||
}, {
|
||||
|
|
Reference in a new issue