Skip to content

Commit

Permalink
fix(youtube/general-ads): hide reels shelf
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Nov 22, 2022
1 parent ee1f895 commit 1f48749
Showing 1 changed file with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ else if (pathRegister.contains(path) || identifierRegister.contains(identifier))
else
result = BlockResult.UNBLOCKED;

LogHelper.debug(
GeneralAdsPatch.class,
String.format("%s (ID: %s): %s", result.message, identifier, path)
);
log(String.format("%s (ID: %s): %s", result.message, identifier, path));

return result.filter;
}
Expand All @@ -138,12 +135,38 @@ private enum BlockResult {
}

/**
* Hide the specific view, which shows ads in the homepage.
* Hide a view.
*
* @param condition The setting to check for hiding the view.
* @param view The view to hide.
*/
private static void hideView(SettingsEnum condition, View view) {
if (!condition.getBoolean()) return;

log("Hiding view with setting: " + condition);

AdRemoverAPI.HideViewWithLayout1dp(view);
}

/**
* Hide the view, which shows ads in the homepage.
*
* @param view The view, which shows ads.
*/
public static void hideAdAttributionView(View view) {
if (!SettingsEnum.ADREMOVER_GENERAL_ADS_REMOVAL.getBoolean()) return;
AdRemoverAPI.HideViewWithLayout1dp(view);
hideView(SettingsEnum.ADREMOVER_GENERAL_ADS_REMOVAL, view);
}

/**
* Hide the view, which shows reels in the homepage.
*
* @param view The view, which shows reels.
*/
public static void hideReelView(View view) {
hideView(SettingsEnum.ADREMOVER_SHORTS_REMOVAL, view);
}

private static void log(String message) {
LogHelper.debug(GeneralAdsPatch.class, message);
}
}

0 comments on commit 1f48749

Please sign in to comment.