mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-16 06:05:37 +07:00
Added catch statements
This commit is contained in:
@@ -42,7 +42,7 @@ function contextMenuStart() {
|
||||
if (!results || results[0] !== true) {
|
||||
return browser.tabs.executeScript(tab.id, {
|
||||
file: "/external_js/clipboard-helper.js",
|
||||
});
|
||||
}).catch(handleError);
|
||||
}
|
||||
}).then(() => {
|
||||
return browser.tabs.executeScript(tab.id, {
|
||||
|
||||
@@ -31,7 +31,7 @@ function resetGlobalLog(){
|
||||
browser.runtime.sendMessage({
|
||||
function: "setData",
|
||||
params: ['log', JSON.stringify(obj)]
|
||||
});
|
||||
}).catch(handleError);
|
||||
|
||||
location.reload();
|
||||
}
|
||||
@@ -72,7 +72,7 @@ function getLog()
|
||||
"url": getDataTableTranslation()
|
||||
}
|
||||
} ).order([3, 'desc']).draw();
|
||||
});
|
||||
}).catch(handleError);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,8 +107,8 @@ function exportGlobalLog() {
|
||||
'url': URL.createObjectURL(blob),
|
||||
'filename': 'ClearURLsLogExport.json',
|
||||
'saveAs': true
|
||||
});
|
||||
});
|
||||
}).catch(handleError);
|
||||
}).catch(handleError);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -99,15 +99,15 @@ function changeSwitchButton(id, storageID)
|
||||
browser.runtime.sendMessage({
|
||||
function: "changeIcon",
|
||||
params: []
|
||||
});
|
||||
}).catch(handleError);
|
||||
}
|
||||
changeVisibility(id, storageID);
|
||||
|
||||
browser.runtime.sendMessage({
|
||||
function: "saveOnExit",
|
||||
params: []
|
||||
});
|
||||
});
|
||||
}).catch(handleError);
|
||||
}).catch(handleError);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -162,17 +162,17 @@ function resetGlobalCounter(){
|
||||
browser.runtime.sendMessage({
|
||||
function: "setData",
|
||||
params: ['globalCounter', 0]
|
||||
});
|
||||
}).catch(handleError);
|
||||
|
||||
browser.runtime.sendMessage({
|
||||
function: "setData",
|
||||
params: ['globalurlcounter', 0]
|
||||
});
|
||||
}).catch(handleError);
|
||||
|
||||
browser.runtime.sendMessage({
|
||||
function: "saveOnExit",
|
||||
params: []
|
||||
});
|
||||
}).catch(handleError);
|
||||
|
||||
globalCounter = 0;
|
||||
globalurlcounter = 0;
|
||||
|
||||
@@ -107,7 +107,7 @@ function getData()
|
||||
} else {
|
||||
$('#logLimit_label').text(translate('setting_log_limit_label', logData.response));
|
||||
}
|
||||
});
|
||||
}).catch(handleError);
|
||||
|
||||
loadData("contextMenuEnabled")
|
||||
.then(() => loadData("historyListenerEnabled"))
|
||||
@@ -122,7 +122,7 @@ function getData()
|
||||
changeSwitchButton("referralMarketing", "referralMarketing");
|
||||
changeSwitchButton("domainBlocking", "domainBlocking");
|
||||
changeSwitchButton("pingBlocking", "pingBlocking");
|
||||
});
|
||||
}).catch(handleError);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,8 +205,8 @@ function exportSettings() {
|
||||
'url': URL.createObjectURL(blob),
|
||||
'filename': 'ClearURLs.conf',
|
||||
'saveAs': true
|
||||
});
|
||||
});
|
||||
}).catch(handleError);
|
||||
}).catch(handleError);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,14 +262,14 @@ function changeSwitchButton(id, storageID)
|
||||
browser.runtime.sendMessage({
|
||||
function: "changeIcon",
|
||||
params: []
|
||||
});
|
||||
}).catch(handleError);
|
||||
}
|
||||
|
||||
browser.runtime.sendMessage({
|
||||
function: "saveOnExit",
|
||||
params: []
|
||||
});
|
||||
});
|
||||
}).catch(handleError);
|
||||
}).catch(handleError);
|
||||
});
|
||||
setSwitchButton(id, storageID);
|
||||
}
|
||||
@@ -279,7 +279,7 @@ function changeSwitchButton(id, storageID)
|
||||
*
|
||||
* @param {string} id ID of the HTML element
|
||||
* @param {string} attribute Name of the attribute used for localization
|
||||
* @param {boolean} tooltip
|
||||
* @param {string} tooltip
|
||||
*/
|
||||
function injectText(id, attribute, tooltip = "")
|
||||
{
|
||||
|
||||
@@ -75,7 +75,7 @@ function saveOnDisk(keys) {
|
||||
});
|
||||
|
||||
console.log(translate('core_save_on_disk'));
|
||||
browser.storage.local.set(json);
|
||||
browser.storage.local.set(json).catch(handleError);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ function genesis() {
|
||||
|
||||
// Start history listener
|
||||
historyListenerStart();
|
||||
}, error);
|
||||
}, handleError);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,14 +164,6 @@ function setData(key, value) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write error on console.
|
||||
*/
|
||||
function error(e) {
|
||||
console.log(translate('core_error'));
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values, if the storage is empty.
|
||||
* @param {Object} items
|
||||
|
||||
@@ -235,9 +235,9 @@ function changeIcon() {
|
||||
checkOSAndroid().then((res) => {
|
||||
if (!res) {
|
||||
if (storage.globalStatus) {
|
||||
browser.browserAction.setIcon({path: "img/clearurls_128x128.png"});
|
||||
browser.browserAction.setIcon({path: "img/clearurls_128x128.png"}).catch(handleError);
|
||||
} else {
|
||||
browser.browserAction.setIcon({path: "img/clearurls_gray_128x128.png"});
|
||||
browser.browserAction.setIcon({path: "img/clearurls_gray_128x128.png"}).catch(handleError);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -252,11 +252,11 @@ function setBadgedStatus() {
|
||||
checkOSAndroid().then((res) => {
|
||||
if (!res && storage.badgedStatus) {
|
||||
let color = storage.badged_color;
|
||||
if(storage.badged_color.charAt(0) !== '#')
|
||||
if (storage.badged_color.charAt(0) !== '#')
|
||||
color = '#' + storage.badged_color;
|
||||
browser.browserAction.setBadgeBackgroundColor({
|
||||
'color': color
|
||||
});
|
||||
}).catch(handleError);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -294,11 +294,15 @@ function decodeURL(url) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of at `key` an object. If the resolved value is `undefined`, the `defaultValue` is returned in its place.
|
||||
*
|
||||
* @param {string} key the key of the object
|
||||
* @param {object} defaultValue the default value
|
||||
*/
|
||||
* Gets the value of at `key` an object. If the resolved value is `undefined`, the `defaultValue` is returned in its place.
|
||||
*
|
||||
* @param {string} key the key of the object
|
||||
* @param {object} defaultValue the default value
|
||||
*/
|
||||
Object.prototype.getOrDefault = function (key, defaultValue) {
|
||||
return this[key] === undefined ? defaultValue : this[key];
|
||||
};
|
||||
};
|
||||
|
||||
function handleError(error) {
|
||||
console.log(translate('core_error') + ":" + error);
|
||||
}
|
||||
Reference in New Issue
Block a user