Initial commit

This commit is contained in:
2021-09-01 21:42:58 +02:00
commit ecd194c1fe
14 changed files with 511 additions and 0 deletions

BIN
src/icons/stream-bypass.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

24
src/index.ts Normal file
View File

@ -0,0 +1,24 @@
// @ts-ignore
chrome.storage.local.get(['all', 'disabled'], function (result) {
let keys = Object.keys(result)
if (keys.indexOf('all') !== -1 && !result['all']) {
return
}
// @ts-ignore
for (let match of matches) {
if (window.location.href.indexOf(match[0]) !== -1) {
if (keys.indexOf('disabled') === -1 || result['disabled'].indexOf(match[0]) === -1) {
let regex = match[1] as RegExp
let matchClass = match[2] as Match
let re
if (regex === null) {
location.assign(matchClass === null ? document.body.innerHTML : matchClass.match(new RegExp('').exec(document.body.innerHTML)))
} else if ((re = regex.exec(document.body.innerHTML)) !== null) {
location.assign(matchClass === null ? re[0] : matchClass.match(re))
}
}
return
}
}
})

34
src/manifest.json Normal file
View File

@ -0,0 +1,34 @@
{
"manifest_version": 2,
"name": "Stream Bypass",
"author": "ByteDream",
"description": "",
"version": "1.0.0",
"homepage_url": "https://github.com/ByteDream/stream-bypass",
"content_scripts": [
{
"all_frames": true,
"matches": [
"*://streamtape.com/*",
"*://vidoza.net/*",
"*://vivo.sx/*",
"*://vupload.com/*"
],
"js": [
"match.js",
"index.js"
]
}
],
"permissions": [
"storage"
],
"browser_action": {
"default_icon": "icons/stream-bypass.png",
"default_title": "Stream Bypass",
"default_popup": "popup/popup.html"
},
"icons": {
"128": "icons/stream-bypass.png"
}
}

43
src/match.ts Normal file
View File

@ -0,0 +1,43 @@
interface Match {
match(match: RegExpMatchArray): string
}
class Streamtape implements Match {
match(match: RegExpMatchArray): string {
return `https://streamtape.com/get_video?${match[0]}`
}
}
class Vivo implements Match {
match(match: RegExpMatchArray): string {
return this.rot47(decodeURIComponent(match[1]))
}
// decrypts a string with the rot47 algorithm (https://en.wikipedia.org/wiki/ROT13#Variants)
rot47(encoded: string): string {
const s = []
for(let i = 0; i < encoded.length; i++) {
const j = encoded.charCodeAt(i)
if((j >= 33) && (j <= 126)) {
s[i] = String.fromCharCode(33+((j+ 14)%94))
} else {
s[i] = String.fromCharCode(j)
}
}
return s.join('')
}
}
class Vupload implements Match {
match(match: RegExpMatchArray): string {
return `https://www3.megaupload.to/${match[0]}/v.mp4`
}
}
// every match HAS to be on an separate line
const matches = [
['streamtape.com', new RegExp(/id=\S*(?=')/gm), new Streamtape()],
['vidoza.net', new RegExp(/(?<=src:(\s*)?")\S*(?=")/gm), null],
['vivo.sx', new RegExp(/source:\s*'(\S+)'/gm), new Vivo()],
['vupload.com', new RegExp(/(?<=class\|)\w*/gm), new Vupload()]
]

23
src/popup/popup.html Normal file
View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="popup.css">
<script src="../match.js"></script>
</head>
<body>
<div id="container">
<div id="all">
<div class="buttons">
<a>On</a>
<a>Off</a>
</div>
</div>
<hr>
<table id="sub-container">
</table>
</div>
<script src="./popup.js"></script>
</body>
</html>

35
src/popup/popup.sass Normal file
View File

@ -0,0 +1,35 @@
body
background-color: #2b2a33
font-weight: bold
max-height: 500px
a, p
color: white
font-size: 16px
margin: 5px 0
a
border: 1px solid #281515
cursor: pointer
font-weight: normal
padding: 5px 8px
&.active
background-color: rgba(255, 65, 65, 0.74)
cursor: default
&.disabled
background-color: grey
cursor: not-allowed
hr
margin: 3px 0
#all
display: flex
justify-content: center
margin: 10px 0

103
src/popup/popup.ts Normal file
View File

@ -0,0 +1,103 @@
function enableAll(enable: boolean) {
// @ts-ignore
chrome.storage.local.set({'all': enable})
// @ts-ignore
for (let button of document.getElementById('sub-container').getElementsByTagName('a')) {
enable ? button.classList.remove('disabled') : button.classList.add('disabled')
}
}
function enableOne(website: string, enable: boolean) {
// @ts-ignore
chrome.storage.local.get(['disabled'], function (result) {
let disabled: string[] = Object.keys(result).length === 0 ? [] : result['disabled']
if (enable && disabled.indexOf(website) !== -1) {
disabled.splice(disabled.indexOf(website), 1)
} else if (!enable && disabled.indexOf(website) === -1) {
disabled.push(website)
} else {
return
}
// @ts-ignore
chrome.storage.local.set({'disabled': disabled})
})
}
// @ts-ignore
chrome.storage.local.get(['all', 'disabled'], function (result) {
let allDisabled = result['all'] !== undefined && !result['all']
let disabled = new Map()
if (allDisabled) {
// @ts-ignore
for (let match of matches) {
disabled.set(match[0], false)
}
} else {
if (Object.keys(result).indexOf('disabled') !== -1) {
for (let disable of result['disabled']) {
disabled.set(disable, false)
}
}
}
let subContainer = document.getElementById('sub-container')
// @ts-ignore
for (let match of matches) {
let row = document.createElement('tr')
let name = document.createElement('td')
let nameValue = document.createElement('p')
nameValue.innerText = match[0]
let buttons = document.createElement('td')
buttons.classList.add('buttons')
let on = document.createElement('a')
on.innerText = 'On'
let off = document.createElement('a')
off.innerText = 'Off'
disabled.has(match[0]) ? off.classList.add('active') : on.classList.add('active')
if (allDisabled) {
on.classList.add('disabled')
off.classList.add('disabled')
}
on.onclick = function () {
if (!on.classList.contains('disabled')) {
enableOne(match[0], true)
on.classList.add('active')
off.classList.remove('active')
}
}
off.onclick = function () {
if (!off.classList.contains('disabled')) {
enableOne(match[0], false)
on.classList.remove('active')
off.classList.add('active')
}
}
name.append(nameValue)
buttons.append(on, off)
row.append(name, buttons)
subContainer.append(row)
}
let allButtons = document.getElementById('all').getElementsByTagName('a')
allButtons[0].onclick = function () {
if (!allButtons[0].classList.contains('disabled')) {
enableAll(true)
allButtons[0].classList.add('active')
allButtons[1].classList.remove('active')
}
}
allButtons[1].onclick = function () {
if (!allButtons[1].classList.contains('disabled')) {
enableAll(false)
allButtons[0].classList.remove('active')
allButtons[1].classList.add('active')
}
}
allDisabled ? allButtons[1].classList.add('active') : allButtons[0].classList.add('active')
})

15
src/tsconfig.json Normal file
View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2015",
"lib": [
"dom",
"es5",
"scripthost",
"es2015.collection"
]
},
"exclude": [
"node_modules"
],
}