You've already forked revanced-integrations
mirror of
https://github.com/revanced/revanced-integrations
synced 2025-11-21 18:35:37 +01:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2bb4a5f03 | ||
|
|
773357d6e6 | ||
|
|
d26b9339fb | ||
|
|
61ed39722e | ||
|
|
54baa3c2e5 | ||
|
|
5dd10f6978 | ||
|
|
9bf804219e |
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -1,6 +1,7 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
@@ -26,9 +27,6 @@ jobs:
|
||||
java-version: '11'
|
||||
distribution: 'zulu'
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew --no-daemon build
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 32
|
||||
namespace 'vanced.integrations'
|
||||
namespace 'app.revanced.integrations'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "revanced.integrationsapp"
|
||||
applicationId "app.revanced.integrations"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 32
|
||||
versionCode 1
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
||||
</manifest>
|
||||
@@ -0,0 +1,179 @@
|
||||
package app.revanced.integrations.adremover;
|
||||
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toolbar;
|
||||
|
||||
import app.revanced.integrations.patches.HideShortsButtonPatch;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
|
||||
/**
|
||||
* API Class that provides the logic to the Patch classes. All methods in here should be protected/private and only be accessed from a Patch class.
|
||||
*/
|
||||
public class AdRemoverAPI {
|
||||
|
||||
/**
|
||||
* Removes Reels and Home ads
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public static void HideViewWithLayout1dp(View view) {
|
||||
if (view instanceof LinearLayout) {
|
||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(1, 1);
|
||||
view.setLayoutParams(layoutParams);
|
||||
} else if (view instanceof FrameLayout) {
|
||||
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(1, 1);
|
||||
view.setLayoutParams(layoutParams2);
|
||||
} else if (view instanceof RelativeLayout) {
|
||||
RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(1, 1);
|
||||
view.setLayoutParams(layoutParams3);
|
||||
} else if (view instanceof Toolbar) {
|
||||
Toolbar.LayoutParams layoutParams4 = new Toolbar.LayoutParams(1, 1);
|
||||
view.setLayoutParams(layoutParams4);
|
||||
} else if (view instanceof ViewGroup) {
|
||||
ViewGroup.LayoutParams layoutParams5 = new ViewGroup.LayoutParams(1, 1);
|
||||
view.setLayoutParams(layoutParams5);
|
||||
} else {
|
||||
LogHelper.debug("XAdRemover", "HideViewWithLayout1dp - Id: " + view.getId() + " Type: " + view.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the Create button
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public static void hideCreateButton(View view) {
|
||||
String message = SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Create button: shown" : "Create button: hidden";
|
||||
LogHelper.debug("HideCreateButton", message);
|
||||
if (!SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
|
||||
view.setVisibility(View.GONE);
|
||||
} else {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the shorts button
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public static void hideShortsButton(View view) {
|
||||
if (HideShortsButtonPatch.lastPivotTab != null && HideShortsButtonPatch.lastPivotTab.name() == "TAB_SHORTS") {
|
||||
String message = SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Shorts button: shown" : "Shorts button: hidden";
|
||||
LogHelper.debug("HideShortsButton", message);
|
||||
if (!SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the InfoCardSuggestions
|
||||
*
|
||||
* @param InfoCardOverlayPresenter
|
||||
* @return
|
||||
*/
|
||||
public static Object removeInfoCardSuggestions(Object InfoCardOverlayPresenter) {
|
||||
if (!SettingsEnum.INFO_CARDS_SHOWN_BOOLEAN.getBoolean()) InfoCardOverlayPresenter = null;
|
||||
String message = InfoCardOverlayPresenter == null ? "RemoveInfoCardSuggestions: true" : "RemoveInfoCardSuggestions: false";
|
||||
LogHelper.debug("AdRemoverAPI", message);
|
||||
return InfoCardOverlayPresenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the Suggestions
|
||||
*
|
||||
* @param showSuggestions
|
||||
* @return
|
||||
*/
|
||||
public static Boolean removeSuggestions(Boolean showSuggestions) {
|
||||
if (!SettingsEnum.SUGGESTIONS_SHOWN_BOOLEAN.getBoolean()) showSuggestions = false;
|
||||
String message = showSuggestions ? "RemoveSuggestions: true" : "RemoveSuggestions: false";
|
||||
LogHelper.debug("AdRemoverAPI", message);
|
||||
return showSuggestions;
|
||||
}
|
||||
|
||||
|
||||
public static int BrandingWatermark(int defaultValue) {
|
||||
if (defaultValue == 0 && !SettingsEnum.BRANDING_SHOWN_BOOLEAN.getBoolean()) {
|
||||
defaultValue = 8;
|
||||
}
|
||||
String message = defaultValue == 8 ? "BrandingWatermark: Removed" : "BrandingWatermark: Shown";
|
||||
LogHelper.debug("AdRemoverAPI", message);
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/*
|
||||
private static void inspectComponentHost(Object item) {
|
||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||||
if (stackTraceElements.length <= 3) {
|
||||
LogHelper.debug("Litho", "Couldn't locate the method called from.");
|
||||
} else {
|
||||
String sb = "Called from method: " +
|
||||
stackTraceElements[3].toString() + "\n";
|
||||
LogHelper.debug("Litho", sb);
|
||||
}
|
||||
if (item == null) {
|
||||
LogHelper.debug("Litho", "Item is null.");
|
||||
} else if (item.getClass().getSimpleName().contains("cwl")) {
|
||||
LogHelper.debug("Litho", "Item is a cwl item.");
|
||||
LogHelper.debug("Litho", getViewHierarchy((ViewGroup) item));
|
||||
} else {
|
||||
LogHelper.debug("Litho", "Item is not a cwl item.");
|
||||
}
|
||||
}
|
||||
|
||||
private static String getViewHierarchy(ViewGroup v) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
printViews(v, buf, 0);
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private static String printViews(ViewGroup v, StringBuffer buf, int level) {
|
||||
int childCount = v.getChildCount();
|
||||
v.getId();
|
||||
indent(buf, level);
|
||||
buf.append(v.getClass().getName());
|
||||
buf.append(" children:");
|
||||
buf.append(childCount);
|
||||
buf.append(" id:").append(v.getId());
|
||||
buf.append("\n");
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View child = v.getChildAt(i);
|
||||
if (child instanceof ViewGroup) {
|
||||
printViews((ViewGroup) child, buf, level + 1);
|
||||
} else {
|
||||
indent(buf, level + 1);
|
||||
buf.append(child.getClass().getName());
|
||||
buf.append(" id:").append(child.getId());
|
||||
buf.append("\n");
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private static void indent(StringBuffer buf, int level) {
|
||||
for (int i = 0; i < level; i++) {
|
||||
buf.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
private static void recursiveLoopChildren(ViewGroup parent) {
|
||||
for (int i = 0; i < parent.getChildCount(); i++) {
|
||||
View child = parent.getChildAt(i);
|
||||
if (child instanceof ViewGroup) {
|
||||
recursiveLoopChildren((ViewGroup) child);
|
||||
child.setVisibility(View.GONE);
|
||||
} else if (child != null) {
|
||||
child.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package fi.razerman.youtube.litho;
|
||||
package app.revanced.integrations.adremover;
|
||||
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
@@ -13,12 +13,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import fi.razerman.youtube.Helpers.SharedPrefs;
|
||||
import fi.razerman.youtube.XGlobals;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||
import app.revanced.integrations.settings.Settings;
|
||||
|
||||
public class LithoAdRemoval {
|
||||
private static boolean getBoolean(String key, boolean _default) {
|
||||
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), key, _default);
|
||||
return SharedPrefHelper.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), SharedPrefHelper.SharedPrefNames.YOUTUBE, key, _default);
|
||||
}
|
||||
|
||||
private static boolean isExperimentalInfoPanelRemoval() {
|
||||
@@ -33,43 +35,43 @@ public class LithoAdRemoval {
|
||||
return getBoolean("experimental_emergency_box", true);
|
||||
}
|
||||
|
||||
public static boolean isExperimentalAdRemoval() {
|
||||
private static boolean isExperimentalAdRemoval() {
|
||||
return getBoolean("experimental_ad_removal", true);
|
||||
}
|
||||
|
||||
public static boolean isExperimentalMerchandiseRemoval() {
|
||||
private static boolean isExperimentalMerchandiseRemoval() {
|
||||
return getBoolean("experimental_merchandise", true);
|
||||
}
|
||||
|
||||
public static boolean isExperimentalCommunityPostRemoval() {
|
||||
private static boolean isExperimentalCommunityPostRemoval() {
|
||||
return getBoolean("experimental_community_posts", false);
|
||||
}
|
||||
|
||||
public static boolean isExperimentalMovieRemoval() {
|
||||
private static boolean isExperimentalMovieRemoval() {
|
||||
return getBoolean("experimental_movie", true);
|
||||
}
|
||||
|
||||
public static boolean isExperimentalCompactBannerRemoval() {
|
||||
private static boolean isExperimentalCompactBannerRemoval() {
|
||||
return getBoolean("experimental_compact_banner", false);
|
||||
}
|
||||
|
||||
public static boolean isExperimentalPaidContentRemoval() {
|
||||
private static boolean isExperimentalPaidContentRemoval() {
|
||||
return getBoolean("experimental_paid_content", true);
|
||||
}
|
||||
|
||||
public static boolean isExperimentalCommentsRemoval() {
|
||||
private static boolean isExperimentalCommentsRemoval() {
|
||||
return getBoolean("experimental_comments", false);
|
||||
}
|
||||
|
||||
public static boolean isInFeedSurvey() {
|
||||
private static boolean isInFeedSurvey() {
|
||||
return getBoolean("experimental_in_feed_survey", false);
|
||||
}
|
||||
|
||||
public static boolean isShortsShelf() {
|
||||
private static boolean isShortsShelf() {
|
||||
return getBoolean("experimental_shorts_shelf", true);
|
||||
}
|
||||
|
||||
public static boolean isCommunityGuidelines() {
|
||||
private static boolean isCommunityGuidelines() {
|
||||
return getBoolean("experimental_community_guidelines", true);
|
||||
}
|
||||
|
||||
@@ -168,20 +170,20 @@ public class LithoAdRemoval {
|
||||
)) return false;
|
||||
|
||||
if (blockList.stream().anyMatch(value::contains)) {
|
||||
if (XGlobals.debug) Log.d("TemplateBlocked", value);
|
||||
LogHelper.debug("TemplateBlocked", value);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!XGlobals.debug) return false;
|
||||
if (!SettingsEnum.DEBUG_BOOLEAN.getBoolean()) return false;
|
||||
if (value.contains("related_video_with_context")) {
|
||||
Log.d("Template", value + " | " + bytesToHex(buffer.array()));
|
||||
LogHelper.debug("Template", value + " | " + bytesToHex(buffer.array()));
|
||||
return false;
|
||||
}
|
||||
Log.d("Template", value);
|
||||
LogHelper.debug("Template", value);
|
||||
return false;
|
||||
} catch (
|
||||
Exception ex) {
|
||||
Log.e("Template", ex.getMessage(), ex);
|
||||
LogHelper.printException("Template", ex.getMessage(), ex);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package fi.vanced.libraries.youtube.whitelisting;
|
||||
package app.revanced.integrations.adremover.whitelist;
|
||||
|
||||
import static fi.razerman.youtube.XGlobals.debug;
|
||||
import static fi.vanced.libraries.youtube.player.VideoInformation.channelName;
|
||||
import static fi.vanced.libraries.youtube.ui.SlimButtonContainer.adBlockButton;
|
||||
import static fi.vanced.libraries.youtube.ui.SlimButtonContainer.sbWhitelistButton;
|
||||
import static fi.vanced.utils.VancedUtils.getPreferences;
|
||||
import static pl.jakubweg.StringRef.str;
|
||||
import static app.revanced.integrations.sponsorblock.player.VideoInformation.channelName;
|
||||
import static app.revanced.integrations.sponsorblock.player.ui.SlimButtonContainer.adBlockButton;
|
||||
import static app.revanced.integrations.sponsorblock.player.ui.SlimButtonContainer.sbWhitelistButton;
|
||||
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||
@@ -22,18 +20,21 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import fi.vanced.libraries.youtube.player.ChannelModel;
|
||||
import fi.vanced.libraries.youtube.player.VideoInformation;
|
||||
import fi.vanced.utils.ObjectSerializer;
|
||||
import fi.vanced.utils.SharedPrefUtils;
|
||||
import fi.vanced.utils.VancedUtils;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.settings.Settings;
|
||||
import app.revanced.integrations.sponsorblock.player.ChannelModel;
|
||||
import app.revanced.integrations.sponsorblock.player.VideoInformation;
|
||||
import app.revanced.integrations.utils.ObjectSerializer;
|
||||
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||
|
||||
public class Whitelist {
|
||||
private static final String TAG = "VI - Whitelisting";
|
||||
private static final Map<WhitelistType, ArrayList<ChannelModel>> whitelistMap = parseWhitelist(YouTubeTikTokRoot_Application.getAppContext());
|
||||
private static final Map<WhitelistType, Boolean> enabledMap = parseEnabledMap(YouTubeTikTokRoot_Application.getAppContext());
|
||||
|
||||
private Whitelist() {}
|
||||
private Whitelist() {
|
||||
}
|
||||
|
||||
// injected calls
|
||||
|
||||
@@ -42,9 +43,7 @@ public class Whitelist {
|
||||
}
|
||||
|
||||
public static void setChannelName(String channelName) {
|
||||
if (debug) {
|
||||
Log.d(TAG, "channel name set to " + channelName);
|
||||
}
|
||||
LogHelper.debug(TAG, "channel name set to " + channelName);
|
||||
VideoInformation.channelName = channelName;
|
||||
|
||||
if (enabledMap.get(WhitelistType.ADS) && adBlockButton != null) {
|
||||
@@ -69,26 +68,23 @@ public class Whitelist {
|
||||
Map<WhitelistType, ArrayList<ChannelModel>> whitelistMap = new EnumMap<>(WhitelistType.class);
|
||||
|
||||
for (WhitelistType whitelistType : whitelistTypes) {
|
||||
SharedPreferences preferences = VancedUtils.getPreferences(context, whitelistType.getPreferencesName());
|
||||
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, whitelistType.getPreferencesName());
|
||||
String serializedChannels = preferences.getString("channels", null);
|
||||
if (serializedChannels == null) {
|
||||
if (debug) {
|
||||
Log.d(TAG, String.format("channels string was null for %s whitelisting", whitelistType));
|
||||
}
|
||||
LogHelper.debug(TAG, String.format("channels string was null for %s whitelisting", whitelistType));
|
||||
whitelistMap.put(whitelistType, new ArrayList<>());
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
ArrayList<ChannelModel> deserializedChannels = (ArrayList<ChannelModel>) ObjectSerializer.deserialize(serializedChannels);
|
||||
if (debug) {
|
||||
Log.d(TAG, serializedChannels);
|
||||
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
|
||||
LogHelper.debug(TAG, serializedChannels);
|
||||
for (ChannelModel channel : deserializedChannels) {
|
||||
Log.d(TAG, String.format("Whitelisted channel %s (%s) for type %s", channel.getAuthor(), channel.getChannelId(), whitelistType));
|
||||
LogHelper.debug(TAG, String.format("Whitelisted channel %s (%s) for type %s", channel.getAuthor(), channel.getChannelId(), whitelistType));
|
||||
}
|
||||
}
|
||||
whitelistMap.put(whitelistType, deserializedChannels);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -101,7 +97,7 @@ public class Whitelist {
|
||||
}
|
||||
Map<WhitelistType, Boolean> enabledMap = new EnumMap<>(WhitelistType.class);
|
||||
for (WhitelistType whitelistType : WhitelistType.values()) {
|
||||
enabledMap.put(whitelistType, SharedPrefUtils.getBoolean(context, whitelistType.getSharedPreferencesName(), whitelistType.getPreferenceEnabledName()));
|
||||
enabledMap.put(whitelistType, SharedPrefHelper.getBoolean(context, whitelistType.getSharedPreferencesName(), whitelistType.getPreferenceEnabledName()));
|
||||
}
|
||||
return enabledMap;
|
||||
}
|
||||
@@ -112,17 +108,14 @@ public class Whitelist {
|
||||
return false;
|
||||
}
|
||||
if (channelName == null || channelName.trim().isEmpty()) {
|
||||
if (debug) {
|
||||
Log.d(TAG, String.format("Can't check whitelist status for %s because channel name was missing", whitelistType));
|
||||
}
|
||||
LogHelper.debug(TAG, String.format("Can't check whitelist status for %s because channel name was missing", whitelistType));
|
||||
|
||||
return false;
|
||||
}
|
||||
List<ChannelModel> whitelistedChannels = whitelistMap.get(whitelistType);
|
||||
for (ChannelModel channel : whitelistedChannels) {
|
||||
if (channel.getAuthor().equals(channelName)) {
|
||||
if (debug) {
|
||||
Log.d(TAG, String.format("Whitelist for channel %s for type %s", channelName, whitelistType));
|
||||
}
|
||||
LogHelper.debug(TAG, String.format("Whitelist for channel %s for type %s", channelName, whitelistType));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -134,10 +127,8 @@ public class Whitelist {
|
||||
for (ChannelModel whitelistedChannel : whitelisted) {
|
||||
String channelId = channel.getChannelId();
|
||||
if (whitelistedChannel.getChannelId().equals(channelId)) {
|
||||
if (debug) {
|
||||
Log.d(TAG, String.format("Tried whitelisting an existing channel again. Old info (%1$s | %2$s) - New info (%3$s | %4$s)",
|
||||
whitelistedChannel.getAuthor(), channelId, channelName, channelId));
|
||||
}
|
||||
LogHelper.debug(TAG, String.format("Tried whitelisting an existing channel again. Old info (%1$s | %2$s) - New info (%3$s | %4$s)",
|
||||
whitelistedChannel.getAuthor(), channelId, channelName, channelId));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -159,8 +150,7 @@ public class Whitelist {
|
||||
String friendlyName = whitelistType.getFriendlyName();
|
||||
if (success) {
|
||||
Toast.makeText(context, str("vanced_whitelisting_removed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Toast.makeText(context, str("vanced_whitelisting_remove_failed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
@@ -169,7 +159,7 @@ public class Whitelist {
|
||||
if (context == null) {
|
||||
return false;
|
||||
}
|
||||
SharedPreferences preferences = getPreferences(context, whitelistType.getPreferencesName());
|
||||
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, whitelistType.getPreferencesName());
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
|
||||
try {
|
||||
@@ -0,0 +1,38 @@
|
||||
package app.revanced.integrations.adremover.whitelist;
|
||||
|
||||
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||
|
||||
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||
|
||||
public enum WhitelistType {
|
||||
ADS(SharedPrefHelper.SharedPrefNames.YOUTUBE, "vanced_whitelist_ads_enabled"),
|
||||
SPONSORBLOCK(SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, "vanced_whitelist_sb_enabled");
|
||||
|
||||
private final String friendlyName;
|
||||
private final String preferencesName;
|
||||
private final String preferenceEnabledName;
|
||||
private final SharedPrefHelper.SharedPrefNames name;
|
||||
|
||||
WhitelistType(SharedPrefHelper.SharedPrefNames name, String preferenceEnabledName) {
|
||||
this.friendlyName = str("vanced_whitelisting_" + name().toLowerCase());
|
||||
this.name = name;
|
||||
this.preferencesName = "whitelist_" + name();
|
||||
this.preferenceEnabledName = preferenceEnabledName;
|
||||
}
|
||||
|
||||
public String getFriendlyName() {
|
||||
return friendlyName;
|
||||
}
|
||||
|
||||
public SharedPrefHelper.SharedPrefNames getSharedPreferencesName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getPreferencesName() {
|
||||
return preferencesName;
|
||||
}
|
||||
|
||||
public String getPreferenceEnabledName() {
|
||||
return preferenceEnabledName;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package fi.vanced.utils.requests;
|
||||
package app.revanced.integrations.adremover.whitelist.requests;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
@@ -10,10 +10,9 @@ import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import fi.vanced.libraries.youtube.whitelisting.requests.WhitelistRoutes;
|
||||
|
||||
public class Requester {
|
||||
private Requester() {}
|
||||
private Requester() {
|
||||
}
|
||||
|
||||
public static HttpURLConnection getConnectionFromRoute(String apiUrl, Route route, String... params) throws IOException {
|
||||
String url = apiUrl + route.compile(params).getCompiledRoute();
|
||||
@@ -1,6 +1,4 @@
|
||||
package fi.vanced.utils.requests;
|
||||
|
||||
import fi.vanced.utils.VancedUtils;
|
||||
package app.revanced.integrations.adremover.whitelist.requests;
|
||||
|
||||
public class Route {
|
||||
private final String route;
|
||||
@@ -10,9 +8,9 @@ public class Route {
|
||||
public Route(Route.Method method, String route) {
|
||||
this.method = method;
|
||||
this.route = route;
|
||||
this.paramCount = VancedUtils.countMatches(route, '{');
|
||||
this.paramCount = countMatches(route, '{');
|
||||
|
||||
if (paramCount != VancedUtils.countMatches(route, '}'))
|
||||
if (paramCount != countMatches(route, '}'))
|
||||
throw new IllegalArgumentException("Not enough parameters");
|
||||
}
|
||||
|
||||
@@ -52,6 +50,15 @@ public class Route {
|
||||
}
|
||||
}
|
||||
|
||||
private int countMatches(CharSequence seq, char c) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < seq.length(); i++) {
|
||||
if (seq.charAt(i) == c)
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public enum Method {
|
||||
GET,
|
||||
POST
|
||||
@@ -1,13 +1,11 @@
|
||||
package fi.vanced.libraries.youtube.whitelisting.requests;
|
||||
package app.revanced.integrations.adremover.whitelist.requests;
|
||||
|
||||
import static fi.razerman.youtube.XGlobals.debug;
|
||||
import static fi.vanced.libraries.youtube.player.VideoInformation.currentVideoId;
|
||||
import static fi.vanced.libraries.youtube.ui.AdButton.TAG;
|
||||
import static fi.vanced.utils.VancedUtils.runOnMainThread;
|
||||
import static pl.jakubweg.StringRef.str;
|
||||
import static app.revanced.integrations.sponsorblock.player.VideoInformation.currentVideoId;
|
||||
import static app.revanced.integrations.utils.ReVancedUtils.runOnMainThread;
|
||||
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
@@ -19,18 +17,18 @@ import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import fi.vanced.libraries.youtube.player.ChannelModel;
|
||||
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
|
||||
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
|
||||
import fi.vanced.utils.VancedUtils;
|
||||
import fi.vanced.utils.requests.Requester;
|
||||
import fi.vanced.utils.requests.Route;
|
||||
import vanced.integrations.BuildConfig;
|
||||
import app.revanced.integrations.settings.Settings;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.sponsorblock.player.ChannelModel;
|
||||
import app.revanced.integrations.adremover.whitelist.Whitelist;
|
||||
import app.revanced.integrations.adremover.whitelist.WhitelistType;
|
||||
import app.revanced.integrations.BuildConfig;
|
||||
|
||||
public class WhitelistRequester {
|
||||
private static final String YT_API_URL = "https://www.youtube.com/youtubei/v1/";
|
||||
|
||||
private WhitelistRequester() {}
|
||||
private WhitelistRequester() {
|
||||
}
|
||||
|
||||
public static void addChannelToWhitelist(WhitelistType whitelistType, View view, ImageView buttonIcon, Context context) {
|
||||
try {
|
||||
@@ -40,9 +38,9 @@ public class WhitelistRequester {
|
||||
connection.setDoOutput(true);
|
||||
connection.setConnectTimeout(2 * 1000);
|
||||
|
||||
String versionName = VancedUtils.getVersionName(context);
|
||||
String versionName = Settings.getVersionName(context);
|
||||
String jsonInputString = "{\"context\": {\"client\": { \"clientName\": \"Android\", \"clientVersion\": \"" + versionName + "\" } }, \"videoId\": \"" + currentVideoId + "\"}";
|
||||
try(OutputStream os = connection.getOutputStream()) {
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
@@ -52,9 +50,7 @@ public class WhitelistRequester {
|
||||
JSONObject videoInfo = json.getJSONObject("videoDetails");
|
||||
ChannelModel channelModel = new ChannelModel(videoInfo.getString("author"), videoInfo.getString("channelId"));
|
||||
String author = channelModel.getAuthor();
|
||||
if (debug) {
|
||||
Log.d(TAG, "channelId " + channelModel.getChannelId() + " fetched for author " + author);
|
||||
}
|
||||
LogHelper.debug("WhitelistRequester", "channelId " + channelModel.getChannelId() + " fetched for author " + author);
|
||||
|
||||
boolean success = Whitelist.addToWhitelist(whitelistType, context, channelModel);
|
||||
String whitelistTypeName = whitelistType.getFriendlyName();
|
||||
@@ -62,18 +58,14 @@ public class WhitelistRequester {
|
||||
if (success) {
|
||||
buttonIcon.setEnabled(whitelistType != WhitelistType.SPONSORBLOCK);
|
||||
Toast.makeText(context, str("vanced_whitelisting_added", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
buttonIcon.setEnabled(whitelistType == WhitelistType.SPONSORBLOCK);
|
||||
Toast.makeText(context, str("vanced_whitelisting_add_failed", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
view.setEnabled(true);
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (debug) {
|
||||
Log.d(TAG, "player fetch response was " + responseCode);
|
||||
}
|
||||
} else {
|
||||
LogHelper.debug("WhitelistRequester", "player fetch response was " + responseCode);
|
||||
runOnMainThread(() -> {
|
||||
Toast.makeText(context, str("vanced_whitelisting_fetch_failed", responseCode), Toast.LENGTH_SHORT).show();
|
||||
buttonIcon.setEnabled(true);
|
||||
@@ -81,9 +73,8 @@ public class WhitelistRequester {
|
||||
});
|
||||
}
|
||||
connection.disconnect();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Log.e(TAG, "Failed to fetch channelId", ex);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException("WhitelistRequester", "Failed to fetch channelId", ex);
|
||||
runOnMainThread(() -> view.setEnabled(true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.revanced.integrations.adremover.whitelist.requests;
|
||||
|
||||
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.POST;
|
||||
|
||||
public class WhitelistRoutes {
|
||||
public static final Route GET_CHANNEL_DETAILS = new Route(POST, "player?key={api_key}");
|
||||
|
||||
private WhitelistRoutes() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import app.revanced.integrations.adremover.LithoAdRemoval;
|
||||
|
||||
public class GeneralBytecodeAdsPatch {
|
||||
|
||||
//Used by app.revanced.patches.youtube.ad.general.bytecode.patch.GeneralBytecodeAdsPatch
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public static boolean containsAd(String value, ByteBuffer buffer) {
|
||||
return LithoAdRemoval.containsAd(value, buffer);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
|
||||
public class HideCastButtonPatch {
|
||||
|
||||
//Used by app.revanced.patches.youtube.layout.castbutton.patch.HideCastButonPatch
|
||||
public static int getCastButtonOverrideV2(int original) {
|
||||
return SettingsEnum.CAST_BUTTON_SHOWN_BOOLEAN.getBoolean() ? original : 8;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import app.revanced.integrations.adremover.AdRemoverAPI;
|
||||
|
||||
public class HideCreateButtonPatch {
|
||||
|
||||
//Todo: Switch BooleanPreferences to Settings class
|
||||
//Used by app.revanced.patches.youtube.layout.createbutton.patch.CreateButtonRemoverPatch
|
||||
public static void hideCreateButton(View view) {
|
||||
AdRemoverAPI.hideCreateButton(view);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import app.revanced.integrations.adremover.AdRemoverAPI;
|
||||
import app.revanced.integrations.settings.Settings;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
|
||||
public class HideHomeAdsPatch {
|
||||
|
||||
/**
|
||||
* Used by package app.revanced.extensions.Extensions
|
||||
* @param view
|
||||
*/
|
||||
public static void HideHomeAds(View view) {
|
||||
if (!SettingsEnum.HOME_ADS_SHOWN_BOOLEAN.getBoolean()) {
|
||||
AdRemoverAPI.HideViewWithLayout1dp(view);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import app.revanced.integrations.adremover.AdRemoverAPI;
|
||||
|
||||
public class HideInfoCardSuggestionsPatch {
|
||||
|
||||
//TODO: Create Patch
|
||||
//Not used yet
|
||||
public static void HideInfoCardSuggestions(Object InfoCardOverlayPresenter) {
|
||||
AdRemoverAPI.removeInfoCardSuggestions(InfoCardOverlayPresenter);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import app.revanced.integrations.adremover.AdRemoverAPI;
|
||||
import app.revanced.integrations.settings.Settings;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
|
||||
public class HideReelsPatch {
|
||||
|
||||
/**
|
||||
* Used by app.revanced.patches.youtube.layout.reels.patch.HideReelsPatch
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public static void HideReel(View view) {
|
||||
if (!SettingsEnum.REEL_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
|
||||
AdRemoverAPI.HideViewWithLayout1dp(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import app.revanced.integrations.adremover.AdRemoverAPI;
|
||||
|
||||
public class HideShortsButtonPatch {
|
||||
|
||||
//Todo: Switch BooleanPreferences to Settings class
|
||||
//Used by app.revanced.patches.youtube.layout.shorts.button.patch.ShortsButtonRemoverPatch
|
||||
public static void hideShortsButton(View view) {
|
||||
AdRemoverAPI.hideShortsButton(view);
|
||||
}
|
||||
|
||||
//Needed for the ShortsButtonRemoverPatch
|
||||
public static Enum lastPivotTab;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import app.revanced.integrations.adremover.AdRemoverAPI;
|
||||
|
||||
public class HideSuggestionsPatch {
|
||||
|
||||
//TODO: Create Patch
|
||||
//Not used yet
|
||||
public static void HideSuggestions(boolean showSuggestions) {
|
||||
AdRemoverAPI.removeSuggestions(showSuggestions);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
|
||||
public class OldStyleQualityPatch {
|
||||
|
||||
//Used by app.revanced.patches.youtube.layout.oldqualitylayout.patch.OldQualityLayoutPatch
|
||||
public static boolean useOldStyleQualitySettings() {
|
||||
return SettingsEnum.OLD_STYLE_QUALITY_SETTINGS_BOOLEAN.getBoolean();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
|
||||
public class SeekbarTappingPatch {
|
||||
|
||||
//Used by app.revanced.patches.youtube.interaction.seekbar.patch.EnableSeekbarTappingPatch
|
||||
public static boolean isTapSeekingEnabled() {
|
||||
return SettingsEnum.TAP_SEEKING_ENABLED_BOOLEAN.getBoolean();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import app.revanced.integrations.adremover.whitelist.Whitelist;
|
||||
|
||||
public class VideoAdsPatch {
|
||||
|
||||
//Used by app.revanced.patches.youtube.ad.general.video.patch.VideoAdsPatch
|
||||
public static boolean shouldShowAds() {
|
||||
return Whitelist.shouldShowAds();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package fi.vanced.libraries.youtube.ryd;
|
||||
package app.revanced.integrations.ryd;
|
||||
|
||||
import static fi.razerman.youtube.XGlobals.debug;
|
||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
|
||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN;
|
||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_NAME;
|
||||
import static pl.jakubweg.StringRef.str;
|
||||
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
|
||||
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN;
|
||||
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
@@ -17,13 +15,15 @@ import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.preference.SwitchPreference;
|
||||
|
||||
import fi.vanced.utils.SharedPrefUtils;
|
||||
import app.revanced.integrations.settings.Settings;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||
|
||||
public class RYDFragment extends PreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getPreferenceManager().setSharedPreferencesName(PREFERENCES_NAME);
|
||||
getPreferenceManager().setSharedPreferencesName(SharedPrefHelper.SharedPrefNames.RYD.getName());
|
||||
|
||||
final Activity context = this.getActivity();
|
||||
|
||||
@@ -36,7 +36,7 @@ public class RYDFragment extends PreferenceFragment {
|
||||
preferenceScreen.addPreference(preference);
|
||||
preference.setKey(PREFERENCES_KEY_RYD_ENABLED);
|
||||
preference.setDefaultValue(false);
|
||||
preference.setChecked(SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED));
|
||||
preference.setChecked(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED));
|
||||
preference.setTitle(str("vanced_ryd_title"));
|
||||
preference.setSummary(str("vanced_ryd_summary"));
|
||||
preference.setOnPreferenceChangeListener((pref, newValue) -> {
|
||||
@@ -47,12 +47,12 @@ public class RYDFragment extends PreferenceFragment {
|
||||
}
|
||||
|
||||
// Clear hint
|
||||
if (debug) {
|
||||
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
|
||||
SwitchPreference preference = new SwitchPreference(context);
|
||||
preferenceScreen.addPreference(preference);
|
||||
preference.setKey(PREFERENCES_KEY_RYD_HINT_SHOWN);
|
||||
preference.setDefaultValue(false);
|
||||
preference.setChecked(SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN));
|
||||
preference.setChecked(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN));
|
||||
preference.setTitle("Hint debug");
|
||||
preference.setSummary("Debug toggle for clearing the hint shown preference");
|
||||
preference.setOnPreferenceChangeListener((pref, newValue) -> true);
|
||||
@@ -1,7 +1,6 @@
|
||||
package fi.vanced.libraries.youtube.ryd;
|
||||
package app.revanced.integrations.ryd;
|
||||
|
||||
public class RYDSettings {
|
||||
public static final String PREFERENCES_NAME = "ryd";
|
||||
public static final String PREFERENCES_KEY_USERID = "userId";
|
||||
public static final String PREFERENCES_KEY_RYD_ENABLED = "ryd-enabled";
|
||||
public static final String PREFERENCES_KEY_RYD_HINT_SHOWN = "ryd_hint_shown";
|
||||
@@ -0,0 +1,56 @@
|
||||
package app.revanced.integrations.ryd;
|
||||
|
||||
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_USERID;
|
||||
import static app.revanced.integrations.ryd.Utils.randomString;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.ryd.requests.RYDRequester;
|
||||
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||
|
||||
public class Registration {
|
||||
private String userId;
|
||||
private Context context;
|
||||
|
||||
public Registration(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId != null ? userId : fetchUserId();
|
||||
}
|
||||
|
||||
private String fetchUserId() {
|
||||
try {
|
||||
if (this.context == null)
|
||||
throw new Exception("Unable to fetch userId because context was null");
|
||||
|
||||
this.userId = SharedPrefHelper.getString(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_USERID, null);
|
||||
|
||||
if (this.userId == null) {
|
||||
this.userId = register();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException("Registration", "Unable to fetch the userId from shared preferences", ex);
|
||||
}
|
||||
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public void saveUserId(String userId) {
|
||||
try {
|
||||
if (this.context == null)
|
||||
throw new Exception("Unable to save userId because context was null");
|
||||
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_USERID, userId);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException("Registration", "Unable to save the userId in shared preferences", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private String register() {
|
||||
String userId = randomString(36);
|
||||
LogHelper.debug("Registration", "Trying to register the following userId: " + userId);
|
||||
return RYDRequester.register(userId, this);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,18 @@
|
||||
package fi.vanced.libraries.youtube.ryd;
|
||||
package app.revanced.integrations.ryd;
|
||||
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
|
||||
public class Utils {
|
||||
private static final String TAG = "VI - RYD - Utils";
|
||||
|
||||
// https://stackoverflow.com/a/157202
|
||||
private static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
private static SecureRandom rnd = new SecureRandom();
|
||||
|
||||
public static String solvePuzzle(String challenge, int difficulty) {
|
||||
byte[] decodedChallenge = Base64.decode(challenge, Base64.NO_WRAP);
|
||||
@@ -20,10 +26,10 @@ public class Utils {
|
||||
int maxCount = (int) (Math.pow(2, difficulty + 1) * 5);
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||
for (int i = 0; i < maxCount; i++) {
|
||||
buffer[0] = (byte)i;
|
||||
buffer[1] = (byte)(i >> 8);
|
||||
buffer[2] = (byte)(i >> 16);
|
||||
buffer[3] = (byte)(i >> 24);
|
||||
buffer[0] = (byte) i;
|
||||
buffer[1] = (byte) (i >> 8);
|
||||
buffer[2] = (byte) (i >> 16);
|
||||
buffer[3] = (byte) (i >> 24);
|
||||
byte[] messageDigest = md.digest(buffer);
|
||||
|
||||
if (countLeadingZeroes(messageDigest) >= difficulty) {
|
||||
@@ -31,9 +37,8 @@ public class Utils {
|
||||
return encode;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Log.e(TAG, "Failed to solve puzzle", ex);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException("RYD Utils", "Failed to solve puzzle", ex);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -62,4 +67,11 @@ public class Utils {
|
||||
}
|
||||
return zeroes;
|
||||
}
|
||||
|
||||
public static String randomString(int len) {
|
||||
StringBuilder sb = new StringBuilder(len);
|
||||
for (int i = 0; i < len; i++)
|
||||
sb.append(AB.charAt(rnd.nextInt(AB.length())));
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
package fi.vanced.libraries.youtube.ryd;
|
||||
|
||||
import static fi.razerman.youtube.XGlobals.debug;
|
||||
package app.revanced.integrations.ryd;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import fi.vanced.libraries.youtube.ryd.requests.RYDRequester;
|
||||
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.ryd.requests.RYDRequester;
|
||||
|
||||
public class Voting {
|
||||
private static final String TAG = "VI - RYD - Voting";
|
||||
|
||||
private Registration registration;
|
||||
private Context context;
|
||||
|
||||
@@ -20,9 +17,7 @@ public class Voting {
|
||||
|
||||
public boolean sendVote(String videoId, int vote) {
|
||||
String userId = registration.getUserId();
|
||||
if (debug) {
|
||||
Log.d(TAG, "Trying to vote the following video: " + videoId + " with vote " + vote + " and userId: " + userId);
|
||||
}
|
||||
LogHelper.debug("Voting", "Trying to vote the following video: " + videoId + " with vote " + vote + " and userId: " + userId);
|
||||
return RYDRequester.sendVote(videoId, userId, vote);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package fi.vanced.libraries.youtube.dialog;
|
||||
package app.revanced.integrations.ryd.dialog;
|
||||
|
||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
|
||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN;
|
||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_NAME;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN;
|
||||
import static pl.jakubweg.StringRef.str;
|
||||
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
|
||||
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN;
|
||||
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
|
||||
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN;
|
||||
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
@@ -18,9 +17,8 @@ import android.os.Build;
|
||||
|
||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||
|
||||
import fi.vanced.utils.SharedPrefUtils;
|
||||
import fi.vanced.utils.VancedUtils;
|
||||
import pl.jakubweg.SponsorBlockSettings;
|
||||
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
public class Dialogs {
|
||||
// Inject call from YT to this
|
||||
@@ -31,14 +29,14 @@ public class Dialogs {
|
||||
|
||||
private static void rydFirstRun(Activity activity) {
|
||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||
boolean enabled = SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED, false);
|
||||
boolean hintShown = SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN, false);
|
||||
boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false);
|
||||
boolean hintShown = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, false);
|
||||
|
||||
// If RYD is enabled or hint has been shown, exit
|
||||
if (enabled || hintShown) {
|
||||
// If RYD is enabled but hint hasn't been shown, mark it as shown
|
||||
if (enabled && !hintShown) {
|
||||
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
|
||||
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -50,20 +48,20 @@ public class Dialogs {
|
||||
builder = new AlertDialog.Builder(activity);
|
||||
}
|
||||
builder.setTitle(str("vanced_ryd"));
|
||||
builder.setIcon(VancedUtils.getIdentifier("reel_dislike_icon", "drawable"));
|
||||
builder.setIcon(ReVancedUtils.getIdentifier("reel_dislike_icon", "drawable"));
|
||||
builder.setCancelable(false);
|
||||
builder.setMessage(str("vanced_ryd_firstrun"));
|
||||
builder.setPositiveButton(str("vanced_enable"),
|
||||
(dialog, id) -> {
|
||||
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
|
||||
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED, true);
|
||||
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
|
||||
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, true);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
builder.setNegativeButton(str("vanced_disable"),
|
||||
(dialog, id) -> {
|
||||
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
|
||||
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED, false);
|
||||
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
|
||||
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
@@ -73,7 +71,7 @@ public class Dialogs {
|
||||
dialog.show();
|
||||
|
||||
// Set black background
|
||||
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, VancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
|
||||
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, ReVancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
|
||||
|
||||
// Set learn more action (set here so clicking it doesn't dismiss the dialog)
|
||||
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(v -> {
|
||||
@@ -85,14 +83,14 @@ public class Dialogs {
|
||||
|
||||
private static void sbFirstRun(Activity activity) {
|
||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||
boolean enabled = SharedPrefUtils.getBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
|
||||
boolean hintShown = SharedPrefUtils.getBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, false);
|
||||
boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
|
||||
boolean hintShown = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, false);
|
||||
|
||||
// If SB is enabled or hint has been shown, exit
|
||||
if (enabled || hintShown) {
|
||||
// If SB is enabled but hint hasn't been shown, mark it as shown
|
||||
if (enabled && !hintShown) {
|
||||
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
|
||||
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -104,20 +102,20 @@ public class Dialogs {
|
||||
builder = new AlertDialog.Builder(activity);
|
||||
}
|
||||
builder.setTitle(str("vanced_sb"));
|
||||
builder.setIcon(VancedUtils.getIdentifier("ic_sb_logo", "drawable"));
|
||||
builder.setIcon(ReVancedUtils.getIdentifier("ic_sb_logo", "drawable"));
|
||||
builder.setCancelable(false);
|
||||
builder.setMessage(str("vanced_sb_firstrun"));
|
||||
builder.setPositiveButton(str("vanced_enable"),
|
||||
(dialog, id) -> {
|
||||
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
|
||||
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, true);
|
||||
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
|
||||
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, true);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
builder.setNegativeButton(str("vanced_disable"),
|
||||
(dialog, id) -> {
|
||||
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
|
||||
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
|
||||
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
|
||||
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
@@ -127,7 +125,7 @@ public class Dialogs {
|
||||
dialog.show();
|
||||
|
||||
// Set black background
|
||||
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, VancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
|
||||
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, ReVancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
|
||||
|
||||
// Set learn more action (set here so clicking it doesn't dismiss the dialog)
|
||||
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(v -> {
|
||||
@@ -1,13 +1,11 @@
|
||||
package fi.vanced.libraries.youtube.ryd.requests;
|
||||
package app.revanced.integrations.ryd.requests;
|
||||
|
||||
import static fi.razerman.youtube.XGlobals.debug;
|
||||
import static fi.vanced.libraries.youtube.player.VideoInformation.dislikeCount;
|
||||
import static fi.vanced.libraries.youtube.ryd.ReturnYouTubeDislikes.TAG;
|
||||
import static fi.vanced.utils.requests.Requester.parseJson;
|
||||
import static app.revanced.integrations.sponsorblock.player.VideoInformation.dislikeCount;
|
||||
import static app.revanced.integrations.adremover.whitelist.requests.Requester.parseJson;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
@@ -16,43 +14,40 @@ import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import fi.vanced.libraries.youtube.ryd.Registration;
|
||||
import fi.vanced.libraries.youtube.ryd.ReturnYouTubeDislikes;
|
||||
import fi.vanced.libraries.youtube.ryd.Utils;
|
||||
import fi.vanced.utils.requests.Requester;
|
||||
import fi.vanced.utils.requests.Route;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.ryd.Registration;
|
||||
import app.revanced.integrations.ryd.ReturnYouTubeDislikes;
|
||||
import app.revanced.integrations.ryd.Utils;
|
||||
import app.revanced.integrations.adremover.whitelist.requests.Requester;
|
||||
import app.revanced.integrations.adremover.whitelist.requests.Route;
|
||||
|
||||
public class RYDRequester {
|
||||
private static final String RYD_API_URL = "https://returnyoutubedislikeapi.com/";
|
||||
|
||||
private RYDRequester() {}
|
||||
private RYDRequester() {
|
||||
}
|
||||
|
||||
public static void fetchDislikes(String videoId) {
|
||||
try {
|
||||
if (debug) {
|
||||
Log.d(TAG, "Fetching dislikes for " + videoId);
|
||||
}
|
||||
LogHelper.debug("RYDRequester", "Fetching dislikes for " + videoId);
|
||||
HttpURLConnection connection = getConnectionFromRoute(RYDRoutes.GET_DISLIKES, videoId);
|
||||
connection.setConnectTimeout(5 * 1000);
|
||||
if (connection.getResponseCode() == 200) {
|
||||
JSONObject json = getJSONObject(connection);
|
||||
int dislikes = json.getInt("dislikes");
|
||||
dislikeCount = dislikes;
|
||||
if (debug) {
|
||||
Log.d(TAG, "dislikes fetched - " + dislikeCount);
|
||||
}
|
||||
LogHelper.debug("RYDRequester", "dislikes fetched - " + dislikeCount);
|
||||
|
||||
|
||||
// Set the dislikes
|
||||
new Handler(Looper.getMainLooper()).post(() -> ReturnYouTubeDislikes.trySetDislikes(ReturnYouTubeDislikes.formatDislikes(dislikes)));
|
||||
}
|
||||
else if (debug) {
|
||||
Log.d(TAG, "dislikes fetch response was " + connection.getResponseCode());
|
||||
} else {
|
||||
LogHelper.debug("RYDRequester", "dislikes fetch response was " + connection.getResponseCode());
|
||||
}
|
||||
connection.disconnect();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
dislikeCount = null;
|
||||
Log.e(TAG, "Failed to fetch dislikes", ex);
|
||||
LogHelper.printException("RYDRequester", "Failed to fetch dislikes", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,65 +59,51 @@ public class RYDRequester {
|
||||
JSONObject json = getJSONObject(connection);
|
||||
String challenge = json.getString("challenge");
|
||||
int difficulty = json.getInt("difficulty");
|
||||
if (debug) {
|
||||
Log.d(TAG, "Registration challenge - " + challenge + " with difficulty of " + difficulty);
|
||||
}
|
||||
LogHelper.debug("RYDRequester", "Registration challenge - " + challenge + " with difficulty of " + difficulty);
|
||||
|
||||
// Solve the puzzle
|
||||
String solution = Utils.solvePuzzle(challenge, difficulty);
|
||||
if (debug) {
|
||||
Log.d(TAG, "Registration confirmation solution is " + solution);
|
||||
}
|
||||
LogHelper.debug("RYDRequester", "Registration confirmation solution is " + solution);
|
||||
|
||||
return confirmRegistration(userId, solution, registration);
|
||||
}
|
||||
else if (debug) {
|
||||
Log.d(TAG, "Registration response was " + connection.getResponseCode());
|
||||
} else {
|
||||
LogHelper.debug("RYDRequester", "Registration response was " + connection.getResponseCode());
|
||||
}
|
||||
connection.disconnect();
|
||||
}
|
||||
catch (Exception ex){
|
||||
Log.e(TAG, "Failed to register userId", ex);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException("RYDRequester", "Failed to register userId", ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String confirmRegistration(String userId, String solution, Registration registration) {
|
||||
try {
|
||||
if (debug) {
|
||||
Log.d(TAG, "Trying to confirm registration for the following userId: " + userId + " with solution: " + solution);
|
||||
}
|
||||
LogHelper.debug("RYDRequester", "Trying to confirm registration for the following userId: " + userId + " with solution: " + solution);
|
||||
|
||||
HttpURLConnection connection = getConnectionFromRoute(RYDRoutes.CONFIRM_REGISTRATION, userId);
|
||||
applyCommonRequestSettings(connection);
|
||||
|
||||
String jsonInputString = "{\"solution\": \"" + solution + "\"}";
|
||||
try(OutputStream os = connection.getOutputStream()) {
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
if (connection.getResponseCode() == 200) {
|
||||
String result = parseJson(connection);
|
||||
if (debug) {
|
||||
Log.d(TAG, "Registration confirmation result was " + result);
|
||||
}
|
||||
LogHelper.debug("RYDRequester", "Registration confirmation result was " + result);
|
||||
|
||||
if (result.equalsIgnoreCase("true")) {
|
||||
registration.saveUserId(userId);
|
||||
if (debug) {
|
||||
Log.d(TAG, "Registration was successful for user " + userId);
|
||||
}
|
||||
LogHelper.debug("RYDRequester", "Registration was successful for user " + userId);
|
||||
|
||||
return userId;
|
||||
}
|
||||
}
|
||||
else if (debug) {
|
||||
Log.d(TAG, "Registration confirmation response was " + connection.getResponseCode());
|
||||
} else {
|
||||
LogHelper.debug("RYDRequester", "Registration confirmation response was " + connection.getResponseCode());
|
||||
}
|
||||
connection.disconnect();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Log.e(TAG, "Failed to confirm registration", ex);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException("RYDRequester", "Failed to confirm registration", ex);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -134,7 +115,7 @@ public class RYDRequester {
|
||||
applyCommonRequestSettings(connection);
|
||||
|
||||
String voteJsonString = "{\"userId\": \"" + userId + "\", \"videoId\": \"" + videoId + "\", \"value\": \"" + vote + "\"}";
|
||||
try(OutputStream os = connection.getOutputStream()) {
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
byte[] input = voteJsonString.getBytes(StandardCharsets.UTF_8);
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
@@ -143,26 +124,20 @@ public class RYDRequester {
|
||||
JSONObject json = getJSONObject(connection);
|
||||
String challenge = json.getString("challenge");
|
||||
int difficulty = json.getInt("difficulty");
|
||||
if (debug) {
|
||||
Log.d(TAG, "Vote challenge - " + challenge + " with difficulty of " + difficulty);
|
||||
}
|
||||
LogHelper.debug("RYDRequester", "Vote challenge - " + challenge + " with difficulty of " + difficulty);
|
||||
|
||||
// Solve the puzzle
|
||||
String solution = Utils.solvePuzzle(challenge, difficulty);
|
||||
if (debug) {
|
||||
Log.d(TAG, "Vote confirmation solution is " + solution);
|
||||
}
|
||||
LogHelper.debug("RYDRequester", "Vote confirmation solution is " + solution);
|
||||
|
||||
// Confirm vote
|
||||
return confirmVote(videoId, userId, solution);
|
||||
}
|
||||
else if (debug) {
|
||||
Log.d(TAG, "Vote response was " + connection.getResponseCode());
|
||||
} else {
|
||||
LogHelper.debug("RYDRequester", "Vote response was " + connection.getResponseCode());
|
||||
}
|
||||
connection.disconnect();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Log.e(TAG, "Failed to send vote", ex);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException("RYDRequester", "Failed to send vote", ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -173,31 +148,26 @@ public class RYDRequester {
|
||||
applyCommonRequestSettings(connection);
|
||||
|
||||
String jsonInputString = "{\"userId\": \"" + userId + "\", \"videoId\": \"" + videoId + "\", \"solution\": \"" + solution + "\"}";
|
||||
try(OutputStream os = connection.getOutputStream()) {
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
if (connection.getResponseCode() == 200) {
|
||||
String result = parseJson(connection);
|
||||
if (debug) {
|
||||
Log.d(TAG, "Vote confirmation result was " + result);
|
||||
}
|
||||
LogHelper.debug("RYDRequester", "Vote confirmation result was " + result);
|
||||
|
||||
|
||||
if (result.equalsIgnoreCase("true")) {
|
||||
if (debug) {
|
||||
Log.d(TAG, "Vote was successful for user " + userId);
|
||||
}
|
||||
LogHelper.debug("RYDRequester", "Vote was successful for user " + userId);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (debug) {
|
||||
Log.d(TAG, "Vote confirmation response was " + connection.getResponseCode());
|
||||
} else {
|
||||
LogHelper.debug("RYDRequester", "Vote confirmation response was " + connection.getResponseCode());
|
||||
}
|
||||
connection.disconnect();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Log.e(TAG, "Failed to confirm vote", ex);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException("RYDRequester", "Failed to confirm vote", ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.revanced.integrations.ryd.requests;
|
||||
|
||||
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.GET;
|
||||
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.POST;
|
||||
|
||||
import app.revanced.integrations.adremover.whitelist.requests.Route;
|
||||
|
||||
public class RYDRoutes {
|
||||
public static final Route SEND_VOTE = new Route(POST, "interact/vote");
|
||||
public static final Route CONFIRM_VOTE = new Route(POST, "interact/confirmVote");
|
||||
public static final Route GET_DISLIKES = new Route(GET, "votes?videoId={video_id}");
|
||||
public static final Route GET_REGISTRATION = new Route(GET, "puzzle/registration?userId={user_id}");
|
||||
public static final Route CONFIRM_REGISTRATION = new Route(POST, "puzzle/registration?userId={user_id}");
|
||||
|
||||
private RYDRoutes() {
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user