add ff2mpv setting + new hosters (#14)

* add Kwik, use unpacker to improve reliabilty

* use packer for filemoon

* use packer for upstream

* add ff2mpv setting + functionality

* Update README.md

* get rid of @types/webextension-polyfill

* Revert "Update README.md"

This reverts commit affb600096.

* Update README.md

* Update info link for ff2mpv

* add kwik to hosters in readme

* removes console.logs

* Delete package-lock.json

* add package-lock.json to .gitignore

* unpack without using eval

* Merge main branch into here

* Add Dropload Hoster

* Add Supervideo Hoster

* Add GoodStream Hoster

* Add hosters to readme and delete console.logs

* Delete package-lock.json

* Fix ff2mpv info url

* Update readme

---------

Co-authored-by: bytedream <bytedream@protonmail.com>
This commit is contained in:
sdaqo
2023-08-08 13:50:18 +02:00
committed by GitHub
parent 00514e4e81
commit 7c45cacd36
10 changed files with 195 additions and 9 deletions

View File

@ -2,6 +2,12 @@ import {getMatch} from "./match/match";
import {storageDelete, storageGet, storageSet} from "./store/store";
import {Match} from "./match/matches";
chrome.runtime.onMessage.addListener((message, sender) => {
if (message.action == "ff2mpv") {
chrome.runtime.sendNativeMessage("ff2mpv", {url: message.url})
.catch((error) => {console.error(error)})
}
})
chrome.webRequest.onBeforeRedirect.addListener(async details => {
// check if redirects origins from a previous redirect

View File

@ -1,5 +1,5 @@
import {getMatch} from "./match/match";
import {storageDelete, storageGet} from "./store/store";
import {storageDelete, storageGet, getSetting} from "./store/store";
import {Match, matches} from "./match/matches";
async function main() {
@ -21,6 +21,10 @@ async function main() {
const url = await match.match(re)
if (await getSetting("ff2mpv")) {
chrome.runtime.sendMessage({action: "ff2mpv", url: url})
}
if (match.replace && !url.includes('.m3u8')) {
const player = document.createElement('video')
player.style.width = '100%'

View File

@ -30,6 +30,7 @@
"permissions": [
"storage",
"webRequest",
"nativeMessaging",
"<all_urls>"
],
"web_accessible_resources": [

View File

@ -55,14 +55,14 @@ class Filemoon implements Match {
id = 'filemoon'
reliability = Reliability.HIGH
domains = [
'filemoon.sx'
'filemoon.sx',
'filemoon.in'
]
regex = new RegExp(/eval\(function\(p,a,c,k,e,d\).*?(?=\<\/script\>)/gms)
async match(match: RegExpMatchArray): Promise<string> {
let unpacked = await unPack(match[0])
let url = unpacked.match(/(?<=file:").*(?=")/)[0]
console.log(url)
return url
}
}
@ -99,7 +99,6 @@ class Mp4Upload implements Match {
async match(match: RegExpMatchArray): Promise<string> {
let unpacked = await unPack(match[0])
console.log(unpacked)
let url = unpacked.match(/(?<=player.src\(").*(?=")/)[0]
return url
}
@ -226,11 +225,56 @@ class Kwik implements Match {
console.log(match[0]);
let unpacked = await unPack(match[0])
let url = unpacked.match(/(?<=source=').*(?=')/)[0]
console.log(url)
return url
}
}
class DropLoad implements Match {
name = 'Dropload'
id = 'dropload'
reliability = Reliability.HIGH
domains = [
'dropload.io'
]
regex = new RegExp(/eval\(function\(p,a,c,k,e,d\).*?(?=\<\/script\>)/gms)
async match(match: RegExpMatchArray): Promise<string> {
let unpacked = await unPack(match[0])
let url = unpacked.match(/(?<=file:").*(?=")/)[0]
return url
}
}
class SuperVideo implements Match {
name = 'Supervideo'
id = 'supervideo'
reliability = Reliability.HIGH
domains = [
'supervideo.tv'
]
regex = new RegExp(/eval\(function\(p,a,c,k,e,d\).*?(?=\<\/script\>)/gms)
async match(match: RegExpMatchArray): Promise<string> {
let unpacked = await unPack(match[0])
let url = unpacked.match(/(?<=file:").*(?=")/)[0]
return url
}
}
class GoodStream implements Match {
name = 'Goodstream'
id = 'goodstream'
reliability = Reliability.NORMAL
domains = [
'goodstream.uno'
]
regex = new RegExp(/(?<=file:\s+").*(?=")/g)
async match(match: RegExpMatchArray): Promise<string> {
return match[0]
}
}
export const matches = [
new Doodstream(),
new Filemoon(),
@ -243,5 +287,8 @@ export const matches = [
new Vidoza(),
new Voe(),
new Vupload(),
new Kwik()
new Kwik(),
new DropLoad(),
new SuperVideo(),
new GoodStream()
]

27
src/store/settings.ts Normal file
View File

@ -0,0 +1,27 @@
import { storageSet, storageGet } from "./store"
export class Setting {
name: string
info_url?: string
constructor(name: string, info_url?: string) {
this.name = name
this.info_url = info_url
}
async enable() {
await storageSet(this.name, true)
}
async disable() {
await storageSet(this.name, false)
}
async get_status() {
return await storageGet(this.name)
}
}
export const Settings = [
new Setting("ff2mpv", "https://github.com/ByteDream/stream-bypass/tree/master#ff2mpv-use-mpv-to-directly-play-streams")
]

View File

@ -66,3 +66,5 @@ export async function disable(match: Match) {
await storageSet('disabled', disabled)
}
}
export const getSetting = storageGet

View File

@ -13,8 +13,16 @@
<a>On</a>
<a>Off</a>
</div>
<p>Hosters</p>
<table id="sub-container">
</table>
<hr class="upper-hr">
<p>Settings</p>
<table id="settings-container">
</table>
</div>
<hr>
<table id="sub-container">
</table>
<a id="error" href="https://github.com/ByteDream/stream-bypass/issues">Something does not work</a>

View File

@ -40,16 +40,26 @@ a {
}
hr {
margin: 3px 0;
&.upper-hr {
width: 100%;
}
}
#all {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
margin: 10px 0
}
.buttons {
margin-bottom: 10px;
}
.low-reliability {
text-decoration: underline;
text-decoration-color: rgb(255, 0, 0);

View File

@ -1,5 +1,6 @@
import {getDisabled, disable, enable, getAllDisabled, enableAll, disableAll} from "../../store/store";
import {matches, Reliability} from "../../match/matches";
import { Settings, Setting } from "../../store/settings";
async function main() {
const disabled = await getDisabled()
@ -52,6 +53,51 @@ async function main() {
subContainer.append(row)
}
const settingsContainer = document.getElementById("settings-container")
for (const s of Settings) {
const row = document.createElement('tr')
const name = document.createElement('td')
const nameValue = document.createElement('p')
nameValue.innerText = s.name
const buttons = document.createElement('td')
buttons.classList.add('buttons')
const on = document.createElement('a')
on.innerText = 'On'
const off = document.createElement('a')
off.innerText = 'Off'
const info = document.createElement('a')
info.target = "_blank"
info.href = s.info_url
info.innerText = "🛈"
await s.get_status() ? on.classList.add('active') : off.classList.add('active')
on.onclick = async function () {
if (!on.classList.contains('disabled')) {
await s.enable()
on.classList.add('active')
off.classList.remove('active')
}
}
off.onclick = async function () {
if (!off.classList.contains('disabled')) {
await s.disable()
on.classList.remove('active')
off.classList.add('active')
}
}
name.append(nameValue)
buttons.append(on, off)
if (s.info_url) {
buttons.append(info)
}
row.append(name, buttons)
settingsContainer.append(row)
}
const allOnButton = document.getElementById('all').getElementsByTagName('a')[0]
const allOffButton = document.getElementById('all').getElementsByTagName('a')[1]