add Kwik, use unpacker to improve reliabilty

This commit is contained in:
sdaqo
2023-04-09 04:48:04 +02:00
parent 7d8d8b6614
commit d98035b8d0
4 changed files with 97 additions and 18 deletions

View File

@ -2,6 +2,7 @@ import {getMatch} from "./match/match";
import {storageDelete, storageGet, storageSet} from "./store/store";
import {Match} from "./match/matches";
chrome.webRequest.onBeforeRedirect.addListener(async details => {
// check if redirects origins from a previous redirect
if (await storageGet('redirect') === undefined) {

View File

@ -3,7 +3,7 @@
"name": "Stream Bypass",
"author": "ByteDream",
"description": "A multi-browser addon / extension for multiple streaming providers which redirects directly to the source video.",
"version": "2.1.6",
"version": "2.1.7",
"homepage_url": "https://github.com/ByteDream/stream-bypass",
"browser_specific_settings": {
"gecko": {

View File

@ -1,3 +1,5 @@
import {unPack} from "./unpack";
export enum Reliability {
HIGH,
NORMAL,
@ -71,41 +73,40 @@ class Filemoon implements Match {
class Mixdrop implements Match {
name = 'Mixdrop'
id = 'mixdrop'
reliability = Reliability.NORMAL
reliability = Reliability.HIGH
domains = [
'mixdrop.co',
'mixdrop.to',
'mixdrop.ch',
'mixdrop.bz'
'mixdrop.bz',
'mixdrop.gl'
]
regex = new RegExp(/(?<=\|)\w{2,}/gm)
regex = new RegExp(/eval\(function\(p,a,c,k,e,d\).*?(?=\<\/script\>)/gms)
async match(match: RegExpMatchArray): Promise<string> {
const prefix = /(?<=\/\/)[a|s](?=-)/.exec(document.body.innerHTML)[0]
const subdomain = match[1].length < match[2].length ? match[1] : match[2]
const domain = match.slice().sort((a, b) => b.length - a.length).find(m => /^[a-z]+$/.test(m))
const id = match[1].length > match[2].length ? match[1] : match[2]
const tld = match.find(m => ['net', 'io', 'to', 'sx', 'com'].indexOf(m) !== -1)
const s = match.slice().sort((a, b) => b.length - a.length).slice(1)[0]
const e_t = match.find(m => m.length === 10 && !isNaN(parseInt(m)))
let unpacked = unPack(match[0])
let url = unpacked.match(/(?<=MDCore.wurl=").*(?=")/)[0]
return `https://${prefix}-${subdomain}.${domain}.${tld}/v/${id}.mp4?s=${s}&e=${e_t}&_t=${e_t}`
return `https:${url}`
}
}
class Mp4Upload implements Match {
name = 'Mp4Upload'
id = 'mp4upload'
reliability = Reliability.NORMAL
reliability = Reliability.HIGH
domains = [
'mp4upload.com'
]
replace = true
regex = new RegExp(/(?<=\|)\w{2,}/gm)
regex = new RegExp(/eval\(function\(p,a,c,k,e,d\).*?(?=\<\/script\>)/gms)
async match(match: RegExpMatchArray): Promise<string> {
let id = match.slice().reduce((a, b) => a.length >= b.length ? a : b)
return `https://www4.mp4upload.com:282/d/${id}/video.mp4`
let unpacked = unPack(match[0])
console.log(unpacked)
let url = unpacked.match(/(?<=player.src\(").*(?=")/)[0]
console.log(url)
return url
}
}
@ -166,7 +167,7 @@ class Upstream implements Match {
domains = [
'upstream.to'
]
regex = new RegExp(/(?<=\|)\w{2,}/gm)
regex = new RegExp(/(?<=\|)\w{2,}/gms)
async match(match: RegExpMatchArray): Promise<string> {
return `https://${match[49]}.upstreamcdn.co/hls/${match[148]}/master.m3u8`
@ -215,6 +216,22 @@ class Vupload implements Match {
}
}
class Kwik implements Match {
name = 'Kwik'
id = 'kwik'
reliability = Reliability.HIGH
domains = [
'kwik.cx'
]
regex = new RegExp(/eval\(function\(p,a,c,k,e,d\).*?(?=\<\/script\>)/gms)
async match(match: RegExpMatchArray): Promise<string> {
let unpacked = unPack(match[0])
let url = unpacked.match(/(?<=source=').*(?=')/)[0]
return url
}
}
export const matches = [
new Doodstream(),
new Filemoon(),
@ -226,5 +243,6 @@ export const matches = [
new Upstream(),
new Vidoza(),
new Voe(),
new Vupload()
new Vupload(),
new Kwik()
]

60
src/match/unpack.ts Normal file
View File

@ -0,0 +1,60 @@
export const unPack = (packed: String): String => {
// Use eval() for the unPack script because else the `env` variable will not be in scope when the eval in the script is called
const scriptlet = String.raw`
//////////////////////////////////////////
// Un pack the code from the /packer/ //
// By matthew@matthewfl.com //
// http://matthewfl.com/unPacker.html //
//////////////////////////////////////////
// version 1.2
(function (code) {
function indent (code) {
try {
var tabs = 0, old=-1, add='';
for(var i=0;i<code.length;i++) {
if(code[i].indexOf("{") != -1) tabs++;
if(code[i].indexOf("}") != -1) tabs--;
if(old != tabs) {
old = tabs;
add = "";
while (old > 0) {
add += "\t";
old--;
}
old = tabs;
}
code[i] = add + code[i];
}
} finally {
tabs = null;
old = null;
add = null;
}
return code;
}
var env = {
eval: function (c) {
code = c;
},
window: {},
document: {}
};
eval("with(env) {" + code + "}");
code = (code+"").replace(/;/g, ";\n").replace(/{/g, "\n{\n").replace(/}/g, "\n}\n").replace(/\n;\n/g, ";\n").replace(/\n\\n/g, "\n");
code = code.split("\n");
code = indent(code);
code = code.join("\n");
return code;
})(${'String.raw`'}` + packed + String.raw`${'`'})`
return eval(scriptlet);
}