Compare commits

..

No commits in common. "c59a28c1261524d990f01f7f4337265cde00ccb2" and "2fea85dfc30d97f106dc7387342827f75cfd38f4" have entirely different histories.

2 changed files with 5 additions and 17 deletions

2
.gitignore vendored
View file

@ -1,2 +0,0 @@
*.zip
*.xpi

View file

@ -3,13 +3,6 @@ if (window.browser === undefined) {
window.browser = window.chrome; window.browser = window.chrome;
} }
function errorLogger(action) {
function log(error) {
console.log(`Error: ${action}:`, error);
}
return log;
}
function createRedirect(id, from, transform) { function createRedirect(id, from, transform) {
return { return {
id: id, id: id,
@ -35,11 +28,11 @@ function updateRedirects(settings) {
transform.password = settings.password; transform.password = settings.password;
} }
const redirects = []; const redirects = [];
if (settings.enabled && settings.instance !== '') { if (settings.enabled) {
redirects.push(createRedirect(1, '||twitter.com', transform)); redirects.push(createRedirect(1, '||twitter.com', transform));
redirects.push(createRedirect(2, '||x.com', transform)); redirects.push(createRedirect(2, '||x.com', transform));
} }
return browser.declarativeNetRequest.updateDynamicRules({ browser.declarativeNetRequest.updateDynamicRules({
addRules: redirects, addRules: redirects,
removeRuleIds: [1, 2], removeRuleIds: [1, 2],
}); });
@ -62,11 +55,8 @@ function setupSettingsForm(settings) {
settings.instance = instance.value; settings.instance = instance.value;
settings.username = username.value; settings.username = username.value;
settings.password = password.value; settings.password = password.value;
browser.storage.local.set(settings) browser.storage.local.set(settings);
.then( updateRedirects(settings);
() => updateRedirects(settings),
errorLogger('browser.storage.local.set')
).catch(errorLogger('updateRedirects'));
}); });
} }
} }
@ -76,4 +66,4 @@ browser.storage.local.get({
instance: '', instance: '',
username: '', username: '',
password: '', password: '',
}).then(setupSettingsForm, errorLogger('browser.storage.local.get')); }).then(setupSettingsForm);