first commit
This commit is contained in:
commit
8c05550242
17
.drone.yml
Normal file
17
.drone.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
kind: pipeline
|
||||||
|
name: default
|
||||||
|
steps:
|
||||||
|
- name: compile-chrome
|
||||||
|
image: roypur/chrome-packer:latest
|
||||||
|
commands:
|
||||||
|
- ./pack-chrome.sh
|
||||||
|
- name: gitea_release
|
||||||
|
image: plugins/gitea-release
|
||||||
|
settings:
|
||||||
|
api_key:
|
||||||
|
from_secret: gitea_token
|
||||||
|
base_url: https://git.purser.it
|
||||||
|
title: ${DRONE_TAG}
|
||||||
|
files: chrome.crx
|
||||||
|
when:
|
||||||
|
event: tag
|
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
*.pyc
|
||||||
|
app/gradle/wrapper/*
|
||||||
|
app/gradlew
|
||||||
|
app/gradlew.bat
|
||||||
|
app/gradle.properties
|
||||||
|
app/build/*
|
||||||
|
app/app/build/*
|
||||||
|
app/app/release/*
|
||||||
|
app/.idea/*
|
||||||
|
app/.gradle/*
|
||||||
|
app/gradle/*
|
||||||
|
chrome/*.png
|
||||||
|
*.crx
|
||||||
|
sources.json
|
31
android/app/build.gradle
Normal file
31
android/app/build.gradle
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
plugins {
|
||||||
|
id 'com.android.application'
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 29
|
||||||
|
buildToolsVersion "30.0.3"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "it.purser.stream"
|
||||||
|
minSdkVersion 25
|
||||||
|
targetSdkVersion 29
|
||||||
|
versionCode 109
|
||||||
|
versionName "109.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testImplementation 'junit:junit:4.+'
|
||||||
|
}
|
21
android/app/proguard-rules.pro
vendored
Normal file
21
android/app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
19
android/app/src/main/AndroidManifest.xml
Normal file
19
android/app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="it.purser.stream">
|
||||||
|
<application
|
||||||
|
android:allowBackup="false"
|
||||||
|
android:fullBackupContent="false"
|
||||||
|
android:icon="@drawable/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@drawable/ic_launcher"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.ProxyStream">
|
||||||
|
<activity android:name="it.purser.stream.ShareActivity">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SEND" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:mimeType="*/*" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
BIN
android/app/src/main/ic_launcher-playstore.png
Normal file
BIN
android/app/src/main/ic_launcher-playstore.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
@ -0,0 +1,69 @@
|
|||||||
|
package it.purser.stream;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class ShareActivity extends Activity {
|
||||||
|
private class Upstream {
|
||||||
|
private Uri uri = null;
|
||||||
|
private String provider = null;
|
||||||
|
private Upstream(Uri uri, String provider) {
|
||||||
|
this.uri = uri;
|
||||||
|
this.provider = provider;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private Upstream getSharedLink() {
|
||||||
|
TreeMap<String,String> domains = new TreeMap<>();
|
||||||
|
domains.put("youtu.be", "youtube");
|
||||||
|
domains.put("youtube.com", "youtube");
|
||||||
|
domains.put("www.youtube.com", "youtube");
|
||||||
|
domains.put("tv.nrk.no", "nrk");
|
||||||
|
domains.put("nx12210.your-storageshare.de", "nextcloud");
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
Bundle bundle = intent.getExtras();
|
||||||
|
for(String key: bundle.keySet()) {
|
||||||
|
try {
|
||||||
|
String txt = (String) bundle.get(key);
|
||||||
|
Uri uri = Uri.parse(txt);
|
||||||
|
String host = uri.getHost().toLowerCase(Locale.ROOT);
|
||||||
|
if(domains.containsKey(host)) {
|
||||||
|
if(host.contains("youtube.com")) {
|
||||||
|
Uri.Builder builder = new Uri.Builder();
|
||||||
|
builder.authority(host);
|
||||||
|
builder.scheme("https");
|
||||||
|
String path = uri.getQueryParameter("v");
|
||||||
|
if(path != null) {
|
||||||
|
builder.path(path);
|
||||||
|
return new Upstream(builder.build(), domains.get(host));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Upstream(uri, domains.get(host));
|
||||||
|
}
|
||||||
|
} catch(Exception e) {}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
Upstream upstream = getSharedLink();
|
||||||
|
if(upstream != null) {
|
||||||
|
Uri.Builder builder = new Uri.Builder();
|
||||||
|
builder.authority("stream.purser.it");
|
||||||
|
builder.scheme("https");
|
||||||
|
builder.path(upstream.uri.getPath());
|
||||||
|
builder.appendQueryParameter("provider", upstream.provider);
|
||||||
|
Intent launch = new Intent(Intent.ACTION_VIEW, builder.build());
|
||||||
|
launch.setPackage("com.android.chrome");
|
||||||
|
launch.putExtra("android.support.customtabs.extra.SESSION", "Proxy Stream");
|
||||||
|
launch.putExtra("android.support.customtabs.extra.TOOLBAR_COLOR", 0xff0000);
|
||||||
|
startActivity(launch);
|
||||||
|
}
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
15
android/app/src/main/res/drawable/ic_launcher.xml
Normal file
15
android/app/src/main/res/drawable/ic_launcher.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<group android:scaleX="1.08"
|
||||||
|
android:scaleY="1.08">
|
||||||
|
<path
|
||||||
|
android:pathData="M50,50m-50,0a50,50 0,1 1,100 0a50,50 0,1 1,-100 0"
|
||||||
|
android:fillColor="#000000"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M30,20l0,60l55,-30z"
|
||||||
|
android:fillColor="#32cd32"/>
|
||||||
|
</group>
|
||||||
|
</vector>
|
4
android/app/src/main/res/values-night/themes.xml
Normal file
4
android/app/src/main/res/values-night/themes.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Theme.ProxyStream" parent="android:Theme.Black"/>
|
||||||
|
</resources>
|
10
android/app/src/main/res/values/colors.xml
Normal file
10
android/app/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="purple_200">#FFBB86FC</color>
|
||||||
|
<color name="purple_500">#FF6200EE</color>
|
||||||
|
<color name="purple_700">#FF3700B3</color>
|
||||||
|
<color name="teal_200">#FF03DAC5</color>
|
||||||
|
<color name="teal_700">#FF018786</color>
|
||||||
|
<color name="black">#FF000000</color>
|
||||||
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
</resources>
|
3
android/app/src/main/res/values/strings.xml
Normal file
3
android/app/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">Proxy Stream</string>
|
||||||
|
</resources>
|
4
android/app/src/main/res/values/themes.xml
Normal file
4
android/app/src/main/res/values/themes.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Theme.ProxyStream.Default" parent="android:Theme.Black"/>
|
||||||
|
</resources>
|
@ -0,0 +1,17 @@
|
|||||||
|
package it.purser.stream;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
public class ExampleUnitTest {
|
||||||
|
@Test
|
||||||
|
public void addition_isCorrect() {
|
||||||
|
assertEquals(4, 2 + 2);
|
||||||
|
}
|
||||||
|
}
|
24
android/build.gradle
Normal file
24
android/build.gradle
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath "com.android.tools.build:gradle:4.1.1"
|
||||||
|
|
||||||
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
// in the individual module build.gradle files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task clean(type: Delete) {
|
||||||
|
delete rootProject.buildDir
|
||||||
|
}
|
10
android/local.properties
Normal file
10
android/local.properties
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
## This file is automatically generated by Android Studio.
|
||||||
|
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||||
|
#
|
||||||
|
# This file should *NOT* be checked into Version Control Systems,
|
||||||
|
# as it contains information specific to your local configuration.
|
||||||
|
#
|
||||||
|
# Location of the SDK. This is only used by Gradle.
|
||||||
|
# For customization when using a Version Control System, please read the
|
||||||
|
# header note.
|
||||||
|
sdk.dir=/home/roypur/Android/Sdk
|
2
android/settings.gradle
Normal file
2
android/settings.gradle
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
include ':app'
|
||||||
|
rootProject.name = "Proxy Stream"
|
17
chrome/manifest.json
Normal file
17
chrome/manifest.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "Proxy Stream",
|
||||||
|
"icons": {
|
||||||
|
"16": "icon-16.png",
|
||||||
|
"19": "icon-19.png",
|
||||||
|
"38": "icon-38.png",
|
||||||
|
"48": "icon-48.png",
|
||||||
|
"128": "icon-128.png"
|
||||||
|
},
|
||||||
|
"version": "116.0",
|
||||||
|
"manifest_version": 3,
|
||||||
|
"permissions": ["tabs"],
|
||||||
|
"action": {
|
||||||
|
"default_title": "Proxy Stream",
|
||||||
|
"default_popup": "popup.html"
|
||||||
|
}
|
||||||
|
}
|
9
chrome/popup.html
Normal file
9
chrome/popup.html
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="script.js"></script>
|
||||||
|
<title>Proxy Stream</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<button>Proxy Stream</button>
|
||||||
|
</body>
|
||||||
|
</html>
|
33
chrome/script.js
Normal file
33
chrome/script.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
let providers = new Map();
|
||||||
|
providers.set("www.youtube.com", "youtube");
|
||||||
|
providers.set("youtube.com", "youtube");
|
||||||
|
providers.set("youtu.be", "youtube");
|
||||||
|
providers.set("tv.nrk.no", "nrk");
|
||||||
|
providers.set("nx12210.your-storageshare.de", "nextcloud");
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
let [button] = document.getElementsByTagName("button");
|
||||||
|
button.addEventListener("click", (ev) => {
|
||||||
|
chrome.tabs.query({currentWindow: true, active: true}, (tabs) => {
|
||||||
|
let oldurl = new URL(tabs[0].url);
|
||||||
|
let newurl = new URL("https://stream.purser.it");
|
||||||
|
let search = new URLSearchParams();
|
||||||
|
let hostname = oldurl.hostname.toLowerCase();
|
||||||
|
if(providers.has(hostname)) {
|
||||||
|
if(hostname.includes("youtube.com")) {
|
||||||
|
let newpath = oldurl.searchParams.get("v");
|
||||||
|
if((newpath instanceof String) || ((typeof newpath) === "string")) {
|
||||||
|
newurl.pathname = "/" + newpath;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newurl.pathname = oldurl.pathname;
|
||||||
|
}
|
||||||
|
search.append("provider", providers.get(hostname));
|
||||||
|
}
|
||||||
|
newurl.search = search.toString();
|
||||||
|
let tab = {};
|
||||||
|
tab.url = newurl.href;
|
||||||
|
chrome.tabs.create(tab);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
9
icons.sh
Executable file
9
icons.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
dir=$(dirname $(realpath $0))
|
||||||
|
svg_data=$(curl --silent https://git.purser.it/roypur/stream-api/raw/branch/master/frontend/favicon-basic.svg)
|
||||||
|
|
||||||
|
echo ${svg_data} | inkscape --export-area-page --export-width=16 --export-height=16 "${dir}/frontend/favicon.svg" --export-filename="${dir}/chrome/icon-16.png"
|
||||||
|
echo ${svg_data} | inkscape --export-area-page --export-width=19 --export-height=19 "${dir}/frontend/favicon.svg" --export-filename="${dir}/chrome/icon-19.png"
|
||||||
|
echo ${svg_data} | inkscape --export-area-page --export-width=38 --export-height=38 "${dir}/frontend/favicon.svg" --export-filename="${dir}/chrome/icon-38.png"
|
||||||
|
echo ${svg_data} | inkscape --export-area-page --export-width=48 --export-height=48 "${dir}/frontend/favicon.svg" --export-filename="${dir}/chrome/icon-48.png"
|
||||||
|
echo ${svg_data} | inkscape --export-area-page --export-width=128 --export-height=128 "${dir}/frontend/favicon.svg" --export-filename="${dir}/chrome/icon-128.png"
|
10
pack-chrome.sh
Executable file
10
pack-chrome.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
dir=$(dirname $(realpath $0))
|
||||||
|
${dir}/icons.sh
|
||||||
|
|
||||||
|
temp_name=$(head -c 20 /dev/random | xxd -p | tr -dc a-f0-9)
|
||||||
|
temp_dir="/tmp/${temp_name}"
|
||||||
|
|
||||||
|
chromium --user-data-dir=${temp_dir} --pack-extension="${dir}/chrome" --pack-extension-key=${HOME}/keys/privkey.pem
|
||||||
|
|
||||||
|
rm -rf ${temp_dir}
|
Loading…
Reference in New Issue
Block a user