1
0
Fork 0

initial commit

This commit is contained in:
Vendicated 2022-11-25 10:46:14 +01:00
commit fbc6ec57d3
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3
49 changed files with 1555 additions and 0 deletions

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="true"
android:supportsRtl="true"
tools:targetApi="31"
>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 KiB

View file

@ -0,0 +1,73 @@
package dev.vendicated.vencord;
import androidx.annotation.NonNull;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Locale;
public class HttpClient {
public static final String VENCORD_BUNDLE_URL = "https://github.com/Vendicated/Vencord/releases/download/devbuild/browser.js";
public static final class HttpException extends IOException {
private final HttpURLConnection conn;
private String message;
public HttpException(HttpURLConnection conn) {
this.conn = conn;
}
@Override
@NonNull
public String getMessage() {
if (message == null) {
try {
message = String.format(
Locale.ENGLISH,
"%d: %s (%s)\n%s",
conn.getResponseCode(),
conn.getResponseMessage(),
conn.getURL().toString(),
readAsText(conn.getErrorStream())
);
} catch (IOException ex) {
message = "Error while building message lmao. Url is " + conn.getURL().toString();
}
}
return message;
}
}
public static String vencord;
public static void fetchVencord() throws IOException {
if (vencord != null) return;
var conn = fetch(VENCORD_BUNDLE_URL);
try (var is = conn.getInputStream()) {
vencord = readAsText(is);
}
}
private static HttpURLConnection fetch(String url) throws IOException {
var conn = (HttpURLConnection) new URL(url).openConnection();
if (conn.getResponseCode() >= 300) {
throw new HttpException(conn);
}
return conn;
}
private static String readAsText(InputStream is) throws IOException {
try (var baos = new ByteArrayOutputStream()) {
int n;
byte[] buf = new byte[16384]; // 16 KB
while ((n = is.read(buf)) > -1) {
baos.write(buf, 0, n);
}
baos.flush();
return baos.toString("UTF-8");
}
}
}

View file

@ -0,0 +1,26 @@
package dev.vendicated.vencord;
import android.util.Log;
public final class Logger {
private static final String TAG = "Vencord";
public static void e(String message) {
Log.e(TAG, message);
}
public static void e(String message, Throwable e) {
Log.e(TAG, message, e);
}
public static void w(String message) {
Log.w(TAG, message);
}
public static void i(String message) {
Log.i(TAG, message);
}
public static void d(String message) {
Log.d(TAG, message);
}
}

View file

@ -0,0 +1,70 @@
package dev.vendicated.vencord;
import androidx.annotation.NonNull;
import android.app.Activity;
import android.os.Bundle;
import android.os.StrictMode;
import android.webkit.WebView;
import java.io.IOException;
public class MainActivity extends Activity {
private WebView wv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
var bar = this.getActionBar();
if (bar != null) bar.hide();
setContentView(R.layout.activity_main);
wv = findViewById(R.id.webview);
explodeAndroid();
wv.setWebViewClient(new VWebviewClient());
wv.setWebChromeClient(new VChromeClient());
var s = wv.getSettings();
s.setJavaScriptEnabled(true);
s.setDomStorageEnabled(true);
s.setAllowFileAccess(true);
try {
HttpClient.fetchVencord();
} catch (IOException ex) {
Logger.e("Failed to fetch Vencord", ex);
return;
}
if (savedInstanceState == null)
wv.loadUrl("https://discord.com/app");
}
@Override
protected void onSaveInstanceState(@NonNull Bundle state)
{
super.onSaveInstanceState(state);
wv.saveState(state);
}
@Override
protected void onRestoreInstanceState(Bundle state)
{
super.onRestoreInstanceState(state);
wv.restoreState(state);
}
private void explodeAndroid() {
StrictMode.setThreadPolicy(
new StrictMode.ThreadPolicy.Builder()
// trolley
.permitNetwork()
.build()
);
}
}

View file

@ -0,0 +1,28 @@
package dev.vendicated.vencord;
import android.webkit.ConsoleMessage;
import android.webkit.WebChromeClient;
import java.util.Locale;
public class VChromeClient extends WebChromeClient {
@Override
public boolean onConsoleMessage(ConsoleMessage msg) {
var m = String.format(Locale.ENGLISH,"[Javascript] %s @ %d: %s", msg.message(), msg.lineNumber(), msg.sourceId());
switch (msg.messageLevel()) {
case LOG:
Logger.i(m);
break;
case DEBUG:
Logger.d(m);
break;
case ERROR:
Logger.e(m);
break;
case WARNING:
Logger.w(m);
break;
}
return true;
}
}

View file

@ -0,0 +1,61 @@
package dev.vendicated.vencord;
import android.graphics.Bitmap;
import android.webkit.*;
import androidx.annotation.Nullable;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;
public class VWebviewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url){
return false;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
view.evaluateJavascript(HttpClient.vencord, null);
}
@Nullable
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest req) {
var uri = req.getUrl();
if (req.isForMainFrame() || req.getUrl().getHost().equals("raw.githubusercontent.com") && req.getUrl().getPath().endsWith(".css")) {
try {
return doFetch(req);
} catch (IOException ex) {
Logger.e("Error during shouldInterceptRequest", ex);
}
}
return null;
}
private WebResourceResponse doFetch(WebResourceRequest req) throws IOException {
var url = req.getUrl().toString();
var conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod(req.getMethod());
for (var h : req.getRequestHeaders().entrySet()) {
conn.setRequestProperty(h.getKey(), h.getValue());
}
var code = conn.getResponseCode();
var msg = conn.getResponseMessage();
conn.getHeaderFields();
var headers = conn.getHeaderFields();
var modifiedHeaders = new HashMap<String, String>(headers.size());
for (var header : headers.entrySet()) {
if (!"Content-Security-Policy".equalsIgnoreCase(header.getKey())) {
modifiedHeaders.put(header.getKey(), header.getValue().get(0));
}
}
if (url.endsWith(".css")) modifiedHeaders.put("Content-Type", "text/css");
return new WebResourceResponse(conn.getHeaderField("Content-Type"), "utf-8", code, msg, modifiedHeaders, conn.getInputStream());
}
}

View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z"/>
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
</vector>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<android.widget.LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</android.widget.LinearLayout>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View file

@ -0,0 +1,3 @@
<resources>
<string name="app_name">Vencord</string>
</resources>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older that API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->
</full-backup-content>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed up.
<include .../>
<exclude .../>
-->
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
</device-transfer>
-->
</data-extraction-rules>