Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
|
8cd3c35966 | ||
|
e00a62645a | ||
|
c59a28c126 | ||
|
b2390e5b54 | ||
|
d486e5a637 |
5 changed files with 22 additions and 8 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.zip
|
||||
*.xpi
|
5
README
5
README
|
@ -1,8 +1,9 @@
|
|||
Private Nitter redirector is a webextension for directing Twitter (X) urls to a
|
||||
private Nitter instance. It supports HTTP basic authentication.
|
||||
|
||||
The extension has been tested with Firefox and Chromium. Safari support is
|
||||
unknown at this moment.
|
||||
The extension has been tested to work with Firefox (both desktop and mobile) and
|
||||
Chromium. When tested on Safari, the authentication did not work, but the
|
||||
redirect did.
|
||||
|
||||
Private Nitter redirector is released under the terms of the Unlicense or, in
|
||||
case you find it unacceptable, The GNU General Public License v3.0 or later.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
<fieldset>
|
||||
|
|
20
dialog.js
20
dialog.js
|
@ -3,6 +3,13 @@ if (window.browser === undefined) {
|
|||
window.browser = window.chrome;
|
||||
}
|
||||
|
||||
function errorLogger(action) {
|
||||
function log(error) {
|
||||
console.log(`Error: ${action}:`, error);
|
||||
}
|
||||
return log;
|
||||
}
|
||||
|
||||
function createRedirect(id, from, transform) {
|
||||
return {
|
||||
id: id,
|
||||
|
@ -28,11 +35,11 @@ function updateRedirects(settings) {
|
|||
transform.password = settings.password;
|
||||
}
|
||||
const redirects = [];
|
||||
if (settings.enabled) {
|
||||
if (settings.enabled && settings.instance !== '') {
|
||||
redirects.push(createRedirect(1, '||twitter.com', transform));
|
||||
redirects.push(createRedirect(2, '||x.com', transform));
|
||||
}
|
||||
browser.declarativeNetRequest.updateDynamicRules({
|
||||
return browser.declarativeNetRequest.updateDynamicRules({
|
||||
addRules: redirects,
|
||||
removeRuleIds: [1, 2],
|
||||
});
|
||||
|
@ -55,8 +62,11 @@ function setupSettingsForm(settings) {
|
|||
settings.instance = instance.value;
|
||||
settings.username = username.value;
|
||||
settings.password = password.value;
|
||||
browser.storage.local.set(settings);
|
||||
updateRedirects(settings);
|
||||
browser.storage.local.set(settings)
|
||||
.then(
|
||||
() => updateRedirects(settings),
|
||||
errorLogger('browser.storage.local.set')
|
||||
).catch(errorLogger('updateRedirects'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -66,4 +76,4 @@ browser.storage.local.get({
|
|||
instance: '',
|
||||
username: '',
|
||||
password: '',
|
||||
}).then(setupSettingsForm);
|
||||
}).then(setupSettingsForm, errorLogger('browser.storage.local.get'));
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"64": "icon-64.png"
|
||||
},
|
||||
"description": "Redirect to and authenticate with a private Nitter instance",
|
||||
"version": "1.0",
|
||||
"version": "1.1",
|
||||
"permissions": [
|
||||
"declarativeNetRequestWithHostAccess",
|
||||
"storage"
|
||||
|
|
Loading…
Reference in a new issue