init
This commit is contained in:
commit
386fd14a92
1
htmx.min.js
vendored
Normal file
1
htmx.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
0
images/icon-128.png
Normal file
0
images/icon-128.png
Normal file
0
images/icon-16.png
Normal file
0
images/icon-16.png
Normal file
13
manifest.json
Normal file
13
manifest.json
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"manifest_version": 3,
|
||||||
|
"name": "Redirecter",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"background": {
|
||||||
|
"service_worker": "service-worker.js",
|
||||||
|
"type": "module"
|
||||||
|
},
|
||||||
|
"permissions": [
|
||||||
|
"webNavigation",
|
||||||
|
"tabs"
|
||||||
|
]
|
||||||
|
}
|
39
service-worker.js
Normal file
39
service-worker.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
chrome.webNavigation.onBeforeNavigate.addListener(({ url, tabId, frameType }) => {
|
||||||
|
if (frameType === 'sub_frame') return
|
||||||
|
|
||||||
|
const match = /https?:\/\/(www\.)?((youtube.com\/watch\?v=(.{11}))|(youtu.be\/(.{11}))).*/.exec(url)
|
||||||
|
if (match) {
|
||||||
|
const videoId = match[4] ?? match[6]
|
||||||
|
chrome.tabs.update(
|
||||||
|
tabId,
|
||||||
|
{ url: `https://piped.video/watch?v=${videoId}` }
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
chrome.tabs.update(
|
||||||
|
tabId,
|
||||||
|
{ url: `https://piped.video` }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
url: [
|
||||||
|
{ hostEquals: 'youtu.be' },
|
||||||
|
{ hostSuffix: 'youtube.com' },
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
chrome.webNavigation.onBeforeNavigate.addListener(({ url, tabId, frameType }) => {
|
||||||
|
if (frameType === 'sub_frame') return
|
||||||
|
|
||||||
|
const match = /\.com\/(.*)/.exec(url)
|
||||||
|
const path = match[1]
|
||||||
|
chrome.tabs.update(
|
||||||
|
tabId,
|
||||||
|
{ url: `https://xcancel.com/${path}` }
|
||||||
|
)
|
||||||
|
}, {
|
||||||
|
url: [
|
||||||
|
{ hostSuffix: 'x.com' },
|
||||||
|
{ hostSuffix: 'twitter.com' },
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue