Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
6
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Invidition
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Booteille
Invidition
Commits
fa5025dd
Unverified
Commit
fa5025dd
authored
Apr 07, 2019
by
Booteille
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bump version 0.7.2
parent
7aa6c8ae
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
20 deletions
+41
-20
CHANGELOG.md
CHANGELOG.md
+5
-0
extension/manifest.json
extension/manifest.json
+1
-1
package.json
package.json
+1
-1
src/background.ts
src/background.ts
+26
-17
src/lib/types.ts
src/lib/types.ts
+3
-0
src/options.ts
src/options.ts
+5
-1
No files found.
CHANGELOG.md
View file @
fa5025dd
...
...
@@ -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
...
...
extension/manifest.json
View file @
fa5025dd
{
"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"
:
[
...
...
package.json
View file @
fa5025dd
{
"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"
:
{},
...
...
src/background.ts
View file @
fa5025dd
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
]
=
option
s
[
key
]
||
config
.
options
[
key
];
options
[
key
]
=
opt
s
[
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
();
}
});
src/lib/types.ts
0 → 100644
View file @
fa5025dd
export
enum
MessageType
{
OptionsUpdated
}
src/options.ts
View file @
fa5025dd
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment