Add front-end for ADL

Signed-off-by: Muntashir Al-Islam <muntashirakon@riseup.net>
This commit is contained in:
Muntashir Al-Islam 2025-03-14 15:25:53 -07:00
parent 3bcfb42f01
commit fad8f99592
6 changed files with 193 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.idea/
.DS_Store
build/
browser/src

1
browser/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
book

9
browser/README.md Normal file
View File

@ -0,0 +1,9 @@
# Welcome!
This website acts as a front-end for the [Android Debloat List](https://github.com/MuntashirAkon/android-debloat-list) (ADL) project and is intended to serve as an always available wiki for the pre-installed applications on Android, commonly known as "bloatware". You can utilize the search button or the sidebar to navigate through the bloatware (requires JavaScript), or you can just append `/bloatware/<package-name>.html` to the homepage URL to navigate to the desired bloatware if available. Each page also has an "Open in App Manager" link that you can follow to view the app info of the selected app (if installed).
## Alternative Front-ends
Here's a list of alternative front-ends that make use of the ADL project:
- [App Manager](https://github.com/MuntashirAkon/AppManager)

13
browser/book.toml Normal file
View File

@ -0,0 +1,13 @@
[book]
authors = ["Muntashir Al-Islam"]
language = "en"
multilingual = false
src = "src"
title = "Android Debloat List"
[output.html]
preferred-dark-theme = "ayu"
additional-css = ["custom.css"]
smart-punctuation = true
no-section-label = true
site-url = "/android-debloat-list/"

34
browser/custom.css Normal file
View File

@ -0,0 +1,34 @@
.tags ul {
list-style-type: none;
padding: 0;
margin: 0;
display: flex;
gap: 10px;
}
.tags ul > li {
border: 1px solid;
padding: 4px 16px;
border-radius: 16px;
font-size: small;
}
.tags ul > li[data-tag=delete] {
color: green;
}
.tags ul > li[data-tag=replace] {
color: purple;
}
.tags ul > li[data-tag=caution] {
color: orange;
}
.tags ul > li[data-tag=unsafe] {
color: red;
}
.refs {
margin-block-start: unset;
}

View File

@ -0,0 +1,135 @@
<?php
const REPO_DIR = __DIR__ . "/..";
const BROWSER_DIR = REPO_DIR . "/browser";
const SRC_DIR = BROWSER_DIR . "/src";
const BLOATWARE_DIR = SRC_DIR . "/bloatware";
const SUMMARY_FILE = SRC_DIR . "/SUMMARY.md";
const SITEMAP_FILE = SRC_DIR . "/sitemap.xml";
# Create bloatware list
$bloatware_list = [];
@mkdir(BLOATWARE_DIR,0777, true);
foreach (scandir(REPO_DIR) as $filename) {
if (!str_ends_with($filename, ".json")) {
continue;
}
$file = REPO_DIR . '/' . $filename;
$type = substr($filename, 0, -5);
try {
$list = json_decode(file_get_contents($file), true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
continue;
}
foreach ($list as $item) {
$id = $item['id'];
$name = $item['label'] ?? $id;
$bloatware_list[$id] = $name;
$content = create_bloatware_item($type, $item);
file_put_contents(BLOATWARE_DIR . "/$id.md", $content);
}
}
asort($bloatware_list);
# Copy readme
copy(BROWSER_DIR . "/README.md", SRC_DIR . "/README.md");
# Create summary
$summary = <<<EOF
# Summary
[Welcome!](README.md)
# Bloatware
EOF;
foreach ($bloatware_list as $id => $name) {
$summary .= "- [". $name ."](bloatware/". $id .".md)\n";
}
file_put_contents(SUMMARY_FILE, $summary);
# Create sitemap
$SITE_NAME = "https://muntashirakon.github.io/android-debloat-list";
$urls = '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';
$urls .= <<<EOF
<url><loc>{$SITE_NAME}</loc></url>
EOF;
foreach ($bloatware_list as $id => $name) {
$urls .= <<<EOF
<url><loc>$SITE_NAME/bloatware/{$id}.html</loc></url>
EOF;
}
$urls .= '</urlset>';
file_put_contents(SITEMAP_FILE, $urls);
exit(0);
// Functions //
function create_bloatware_item(string $type, array $item): string {
$id = $item["id"];
$name = $item['label'] ?? $id;
$description = str_replace("\n", "\n\n", trim($item["description"]));
$warning = isset($item['warning']) ? <<<EOF
<div class="warning">
{$item['warning']}
</div>
EOF : "";
$removal = $item['removal'];
$removal_name = removal_to_string($item['removal']);
$type_tag = type_to_string($type);
$web = "";
if (isset($item["web"])) {
$web = "## References { .refs }\n";
foreach ($item["web"] as $num => $link) {
$n = $num + 1;
$web .= "{$n}. <{$link}>\n";
}
}
return <<<EOF
# {$name}
`{$id}`
<div class="tags">
<ul>
<li data-tag={$type}>{$type_tag}</li>
<li data-tag={$removal}>{$removal_name}</li>
</ul>
</div>
{$warning}
{$description}
{$web}
<a href="app-manager://details?id={$id}">Open in App Manager</a>
EOF;
}
function type_to_string(string $type): string {
switch ($type) {
case "aosp": return '<i class="fa fa-android"></i> AOSP';
case "carrier": return '<i class="fa fa-signal"></i> Carrier';
case "google": return '<i class="fa fa-google"></i> Google';
case "misc": return "Others";
case "oem": return '<i class="fa fa-microchip"></i> OEM';
case "pending": return "Pending";
default: throw new Exception("Invalid type: $type");
}
}
function removal_to_string(string $removal_name): string {
switch ($removal_name) {
case "delete": return "Safe to delete";
case "replace": return "Replace with alternative";
case "caution": return "Exercise caution";
case "unsafe": return "Unsafe";
default: throw new Exception("Invaid removal: $removal_name");
}
}