Commit fa5025dd authored by Booteille's avatar Booteille

bump version 0.7.2

parent 7aa6c8ae
......@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.7.2] - 2019-04-07
### Fixed
- Remove forgotten console.log()
- Fix issue with instance not being updated correctly.
## [0.7.1] - 2019-04-06
### Fixed
- No longer redirect instance subdomains to the main domain
......
{
"manifest_version": 2,
"name": "Invidition",
"version": "0.7.0",
"version": "0.7.2",
"description": "Redirects YouTube links and embeds to their Invidious counterpart without any call to YouTube.",
"homepage_url": "https://gitlab.com/Booteille/Invidition",
"permissions": [
......
{
"name": "invidition",
"version": "0.6.0",
"version": "0.7.2",
"description": "Redirects YouTube links and embeds to their Invidious counterpart without any call to YouTube.",
"main": "webpack.config.js",
"dependencies": {},
......
import * as browser from 'webextension-polyfill';
import config from './lib/config';
import * as _ from 'lodash';
import { MessageType } from './lib/types';
let tabsToReload = [];
let options: any = {};
const invidition = async (r) => {
// If extension is disabled, do not redirect
......@@ -12,8 +14,6 @@ const invidition = async (r) => {
let url = new URL(r.url);
const options: any = await getOptions();
// Have to workaround Iframe API
if (url.pathname === '/iframe_api') {
url.href = browser.extension.getURL('/assets/js/youtube/iframe_api.js');
......@@ -104,16 +104,12 @@ const handleTabActivation = async (tab) => {
}
}
const getOptions = async () => {
const options = await browser.storage.sync.get();
let result = {};
const loadOptions = async () => {
const opts = await browser.storage.sync.get();
_.forEach(config.options, (value, key) => {
result[key] = options[key] || config.options[key];
options[key] = opts[key] || config.options[key];
})
return result;
}
const generateSubdomain = () => {
......@@ -124,7 +120,7 @@ const generateSubdomain = () => {
domains.push(`www.${value}`);
})
const instance = new URL(config.options.instance);
const instance = new URL(options.instance);
domains.push(instance.hostname);
domains.push(`www.${instance.hostname}`);
......@@ -142,23 +138,36 @@ const generateIconsPaths = (disabled = false) => {
return paths;
};
const generateFilter = (): string[] => {
const generateFilter = async () => {
let urls: string[] = [];
await loadOptions();
_.forEach(config.domains.toRedirect, (value) => {
urls.push(`*://*.${value}/*`);
})
urls.push(`*://*.${(new URL(config.options.instance)).hostname}/*`);
urls.push(`*://*.${(new URL(options.instance)).hostname}/*`);
return urls;
};
browser.webRequest.onBeforeRequest.addListener(
invidition,
{ urls: generateFilter() },
['blocking']
);
const reloadInviditionListener = async () => {
await loadOptions();
browser.webRequest.onBeforeRequest.removeListener(invidition);
browser.webRequest.onBeforeRequest.addListener(
invidition,
{ urls: await generateFilter() },
['blocking']
);
};
reloadInviditionListener();
browser.browserAction.onClicked.addListener(toogleEnabled);
browser.tabs.onActivated.addListener(handleTabActivation);
browser.runtime.onMessage.addListener((message) => {
switch(message.type) {
case MessageType.OptionsUpdated:
return reloadInviditionListener();
}
});
export enum MessageType {
OptionsUpdated
}
......@@ -2,6 +2,7 @@ import config from './lib/config.ts';
import * as browser from 'webextension-polyfill';
import * as _ from 'lodash';
import ISO6391 from 'iso-639-1';
import { MessageType } from './lib/types';
// When saving options
function saveOptions(e) {
......@@ -27,7 +28,11 @@ function saveOptions(e) {
}
}
// Save settings
browser.storage.sync.set(options);
// Reload Options
let sending = browser.runtime.sendMessage( { type: MessageType.OptionsUpdated });
}
// When options page is loaded
......@@ -43,7 +48,6 @@ function restoreOptions() {
if (option === 'autoplay') {
inputElement.checked = value === '1';
} else {
console.log(value);
inputElement.checked = value === 'true';
}
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment