chore: merge dev to main (#155)

This commit is contained in:
Ushie 2023-08-01 02:18:26 +03:00 committed by GitHub
commit 558d0668da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 2542 additions and 961 deletions

2
.env
View File

@ -1 +1 @@
RV_API_URL="https://releases.revanced.app"
RV_API_URL="https://api.revanced.app"

View File

@ -1,7 +1,6 @@
.DS_Store
node_modules
/build
/testing-docs
/public
/.svelte-kit
/package

View File

@ -2,12 +2,6 @@
The official ReVanced Website.
## Documentation
The documentation you see on the live website is generated from a collection of markup files found in [this git repository](https://github.com/revanced/revanced-documentation). The documentation "generator" currently supports asciidoc and markdown.
It looks for markup files in the `testing-docs` folder by default, but you can specify a different path by changing the `REVANCED_DOCS_FOLDER` environment variable.
## Developing
Install dependencies with `npm install` (or `pnpm install`).

View File

@ -1,20 +0,0 @@
#!/bin/bash
set -e
# CD to the directory of this script.
cd "$(dirname "$0")"
docs_git_repo="${REVANCED_DOCS_REPO:-https://github.com/revanced/revanced-documentation.git}"
git clone "$docs_git_repo" "_docs_src"
# TODO: transform a tag links so this works properly...
#export REVANCED_DOCS_FOLDER="_docs_src/docs"
#git clone --recurse-submodules "$docs_git_repo" "_docs_src"
# Copy assets from docs repo to here.
# mkdir -p static/docs
# cp -r "$REVANCED_DOCS_FOLDER"/assets static/docs/assets || true
npm run build

View File

@ -25,9 +25,11 @@
"prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.8.1",
"sass": "^1.55.0",
"semver": "^7.5.4",
"sirv-cli": "^2.0.2",
"svelte": "^3.54.0",
"svelte-check": "^2.9.2",
"svelte-meta-tags": "^2.8.0",
"tslib": "^2.4.1",
"typescript": "^4.9.3",
"vite": "^4.0.0",

2275
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
import * as settings from './settings';
// API Endpoints
import type { Patch, Repository, Tool } from '$lib/types';
import type { Patch, Repository, Metadata, Asset } from '$lib/types';
export type ReposData = Repository[];
export type PatchesData = { patches: Patch[]; packages: string[] };
export type ToolsData = { [repo: string]: Tool };
export type ReleaseData = { metadata: Metadata; assets: Asset[] };
async function get_json(endpoint: string) {
const url = `${settings.api_base_url()}/${endpoint}`;
@ -16,48 +16,20 @@ async function repositories(): Promise<ReposData> {
return await get_json('contributors').then((json) => json.repositories);
}
async function tools(): Promise<ToolsData> {
const json = await get_json('tools');
// Make the data easier to work with.
let map: Map<string, Tool> = new Map();
for (const tool of json['tools']) {
const repo: string = tool.repository;
if (!map.has(repo)) {
map.set(repo, {
version: tool.version,
repository: repo,
// Just use the timestamp of the first one we find.
timestamp: tool.timestamp,
assets: []
});
}
let value = map.get(repo)!!;
value.assets.push({
name: tool.name,
size: tool.size,
url: tool.browser_download_url,
content_type: tool.content_type
});
map.set(repo, value);
}
return Object.fromEntries(map);
}
async function manager(): Promise<Tool> {
return await tools().then((data) => data['revanced/revanced-manager']);
async function manager(): Promise<ReleaseData> {
const json = await get_json('v2/revanced-manager/releases/latest');
// console.log(json.release.metadata.tag_name);
console.log(json.release.assets[0].browser_download_url);
return { metadata: json.release.metadata, assets: json.release.assets };
}
async function patches(): Promise<PatchesData> {
const json = await get_json('patches');
const json = await get_json('v2/patches/latest');
const packagesWithCount: { [key: string]: number } = {};
// gets packages and patch count
for (let i = 0; i < json.length; i++) {
json[i].compatiblePackages.forEach((pkg: Patch) => {
for (let i = 0; i < json.patches.length; i++) {
json.patches[i].compatiblePackages.forEach((pkg: Patch) => {
packagesWithCount[pkg.name] = (packagesWithCount[pkg.name] || 0) + 1;
});
}
@ -67,7 +39,7 @@ async function patches(): Promise<PatchesData> {
.sort((a, b) => b[1] - a[1])
.map((pkg) => pkg[0]);
return { patches: json, packages };
return { patches: json.patches, packages };
}
export const staleTime = 5 * 60 * 1000;

View File

@ -106,6 +106,13 @@
align-items: center;
}
@media screen and (max-width: 768px) {
.footer-bottom {
flex-wrap: wrap;
gap: 1rem;
}
}
#logo-name {
font-size: 1.4rem;
color: var(--white);
@ -119,7 +126,7 @@
.footer-bottom a {
text-decoration: none;
color: var(--grey-five);
font-weight: 500;
font-weight: 600;
}
li {
@ -131,7 +138,7 @@
li a {
color: var(--accent-color);
font-weight: 500;
font-weight: 600;
font-size: 0.95rem;
}
@ -193,4 +200,8 @@
}
}
svg {
padding-left: 15px;
padding-right: 15px;
}
</style>

View File

@ -19,7 +19,10 @@
<span>
{title}
</span>
<span>{expanded ? '-' : '+'}</span>
<img
src="/icons/{expanded ? 'expand_less' : 'expand_more'}.svg"
alt={expanded ? 'Close' : 'Expand'}
/>
</button>
{#if expanded}
<ul transition:slide|local={{ easing: quintOut, duration: 500 }}>
@ -33,7 +36,7 @@
list-style: none;
color: var(--grey-five);
font-size: 0.9rem;
font-weight: 500;
font-weight: 600;
}
ul {
@ -70,4 +73,8 @@
display: none;
}
}
img {
height: 24px;
}
</style>

View File

@ -9,7 +9,7 @@
Customize your mobile experience through ReVanced <br /> by applying patches to your applications.
</p>
<div class="hero-buttons">
<Button icon="download" type="filled" href="download">Download Manager</Button>
<Button icon="download" type="filled" href="download">Download</Button>
<Button icon="docs" type="tonal" href="patches">View patches</Button>
</div>
</div>

View File

@ -1,16 +1,16 @@
<script>
export let dropdown = false;
export let check = false;
export let selected = false;
export let selected = false;
</script>
<button class:selected on:click>
{#if check}
<img id="check" src="/icons/check.svg" alt="selected" />
{/if}
{#if check}
<img id="check" src="/icons/check.svg" alt="selected" />
{/if}
<slot />
{#if dropdown}
<img id="dropdown" src="/icons/arrow.svg" alt="dropdown" />
<img id="dropdown" src="/icons/expand_more.svg" alt="dropdown" />
{/if}
</button>
@ -31,20 +31,20 @@
gap: 8px;
}
.selected {
background-color: var(--accent-low-opacity);
color: var(--accent-color);
}
.selected {
background-color: var(--accent-low-opacity);
color: var(--accent-color);
}
img {
height: 18px;
}
#dropdown {
margin-right: -6px;
}
#dropdown {
margin-right: -6px;
}
#check {
margin-left: -6px;
}
#check {
margin-left: -6px;
}
</style>

View File

@ -1,49 +1,49 @@
export interface Contributor {
login: string;
avatar_url: string;
html_url: string;
login: string;
avatar_url: string;
html_url: string;
}
export interface Repository {
name: string;
contributors: Contributor[];
name: string;
contributors: Contributor[];
}
export interface Patch {
name: string;
description: string;
version: string;
excluded: boolean;
deprecated: boolean;
dependencies: string[];
options: PatchOption[];
compatiblePackages: CompatiblePackage[];
name: string;
description: string;
version: string;
excluded: boolean;
dependencies: string[];
options: PatchOption[];
compatiblePackages: CompatiblePackage[];
}
export interface CompatiblePackage {
name: string;
versions: string[];
name: string;
versions: string[];
}
export interface PatchOption {
key: string;
title: string;
description: string;
required: boolean;
choices: string[];
key: string;
title: string;
description: string;
required: boolean;
choices: string[];
}
export interface Asset {
name: string;
size: string|null;
url: string;
content_type: string;
};
export interface Tool {
repository: string;
version: string;
timestamp: string;
assets: Asset[];
};
name: string;
content_type: string;
browser_download_url: string;
}
export interface Metadata {
tag_name: string;
name: string;
draft: boolean;
prerelease: boolean;
created_at: string;
published_at: string;
body: string;
}

View File

@ -4,10 +4,38 @@
import SocialHost from '$layout/Hero/SocialHost.svelte';
import Wave from '$lib/components/Wave.svelte';
import Meta from '$lib/components/Meta.svelte';
import { JsonLd } from 'svelte-meta-tags';
</script>
<Meta />
<JsonLd
schema={{
'@context': 'https://schema.org',
'@type': 'WebPage',
name: 'ReVanced',
abstract: 'Continuing the legacy of Vanced',
breadcrumb: 'Home',
publisher: {
'@type': 'Organization',
name: 'ReVanced',
url: 'https://revanced.app/',
logo: {
'@type': 'ImageObject',
url: 'https://revanced.app/embed.png'
},
sameAs: [
'https://github.com/revanced',
'https://twitter.com/revancedapp',
'https://revanced.app/discord',
'https://www.reddit.com/r/revancedapp',
'https://t.me/app_revanced',
'https://www.youtube.com/@ReVanced'
]
}
}}
/>
<main>
<div class="wrap">
<div class="wrappezoid">

View File

@ -5,6 +5,7 @@
import ContributorHost from './ContributorSection.svelte';
import Footer from '$layout/Footer/FooterHost.svelte';
import Meta from '$lib/components/Meta.svelte';
import { JsonLd } from 'svelte-meta-tags';
import Query from '$lib/components/Query.svelte';
import { queries } from '$data/api';
@ -14,6 +15,32 @@
</script>
<Meta title="Contributors" />
<JsonLd
schema={{
'@context': 'https://schema.org',
'@type': 'WebPage',
name: 'ReVanced Contributors',
abstract: 'A list of everyone that has contributed to ReVanced',
breadcrumb: 'Home > Contributors',
publisher: {
'@type': 'Organization',
name: 'ReVanced',
url: 'https://revanced.app/',
logo: {
'@type': 'ImageObject',
url: 'https://revanced.app/embed.png'
},
sameAs: [
'https://github.com/revanced',
'https://twitter.com/revancedapp',
'https://revanced.app/discord',
'https://www.reddit.com/r/revancedapp',
'https://t.me/app_revanced',
'https://www.youtube.com/@ReVanced'
]
}
}}
/>
<main>
<div class="wrapper">

View File

@ -27,7 +27,7 @@
<img
id="arrow"
style:transform={expanded ? 'rotate(0deg)' : 'rotate(-180deg)'}
src="/icons/arrow.svg"
src="/icons/expand_less.svg"
alt="dropdown"
/>
</div>

View File

@ -1,10 +0,0 @@
import type { LayoutServerLoad } from './$types';
import { index_content } from './documentation.server';
// The load function here used to get data from a json file created by a (prerendered) server route.
// This was because we could not prerender the documentation route before.
// If you can no longer prerender the docs, then you are going to have to move the load functions here to a prerendered server route like before and fetch them here.
export const prerender = true;
export const load: LayoutServerLoad = () => ({ tree: index_content() });

View File

@ -1,37 +0,0 @@
<script lang="ts">
import type { LayoutData } from './$types';
import DocsNavTree from './DocsNavTree.svelte';
import Footer from '$layout/Footer/FooterHost.svelte';
export let data: LayoutData;
</script>
<section id="doc-section-main">
<div class="menu">
<DocsNavTree tree={data.tree} />
</div>
<slot />
</section>
<Footer />
<style lang="scss">
#doc-section-main {
margin-inline: auto;
width: min(90%, 90rem);
margin-top: 8rem;
margin-bottom: 5rem;
}
.menu {
display: flex;
flex-direction: column;
gap: 1rem;
}
#doc-section-main {
display: grid;
grid-template-columns: 320px 3fr;
gap: 3rem;
}
</style>

View File

@ -1,56 +0,0 @@
<script lang="ts">
import type { DocumentInfo } from './documentation.shared';
export let info: DocumentInfo;
import { page } from '$app/stores';
</script>
<!-- Always part of a list -->
<li>
<a href="/docs/{info.slug}">
<div class="doc-section item" class:selected={$page.url.pathname === `/docs/${info.slug}`}>
<h5>{info.title}</h5>
</div>
</a>
</li>
<style>
a {
text-decoration: none;
}
li {
list-style: none;
}
.item {
padding: 0.6rem 1rem;
border-radius: 8px;
cursor: pointer;
display: flex;
align-items: center;
gap: 0.6rem;
width: 100%;
user-select: none;
transition: background-color 0.4s var(--bezier-one);
}
.item h5 {
color: var(--grey-five);
transition: color 0.3s var(--bezier-one);
}
.selected h5 {
color: var(--grey-four);
transition: color 0.3s var(--bezier-one);
}
.selected {
background-color: var(--accent-color);
}
.item:hover:not(.selected) {
background-color: var(--grey-six);
}
.item:not(.selected):hover h5 {
color: var(--white);
}
</style>

View File

@ -1,37 +0,0 @@
<script lang="ts">
import { is_tree, assert_is_info_node } from './documentation.shared';
import type { DocsTree } from './documentation.shared';
import DocsNavNode from './DocsNavNode.svelte';
export let tree: DocsTree;
// How deeply nested this is.
export let nested = 0;
</script>
{#if nested}
<!-- The index should be part of the `ul` above us. -->
<DocsNavNode info={tree.index} />
{/if}
<ul>
{#if !nested}
<!-- There is no `ul` above us, so index should go here instead. -->
<DocsNavNode info={tree.index} />
{/if}
{#each tree.nodes as node}
{#if is_tree(node)}
<!-- Recursion here is fine. We are not dealing with a tree the size of a linux root file system. -->
<svelte:self tree={node} nested={nested + 1} />
{:else}
<DocsNavNode info={assert_is_info_node(node)} />
{/if}
{/each}
</ul>
<style>
ul {
padding-left: 1rem;
}
</style>

View File

@ -1,17 +0,0 @@
import type { PageServerLoad } from './$types';
import { error } from '@sveltejs/kit';
import { get } from '../documentation.server';
// See also: ../+layout.server.ts
export const prerender = true;
export const load: PageServerLoad = ({ params }) => {
const document = get(params.slug);
if (document === null) {
error;
throw error(404);
}
return document;
};

View File

@ -1,17 +0,0 @@
<script lang="ts">
import Meta from '$lib/components/Meta.svelte';
import type { PageData } from './$types';
import '../documentation.scss';
// Data here comes from a trusted source.
// CSS comes from the layout.
export let data: PageData;
</script>
<Meta title="Docs" />
<div id="markup-content">
<h1 class="title">{data.title}</h1>
{@html data.content}
</div>

View File

@ -1,95 +0,0 @@
#markup-content {
/* Defaults for text */
color: var(--accent-color-two);
font-weight: 300;
font-size: 1rem;
line-height: 1.75rem;
letter-spacing: 0.03rem !important;
a {
text-decoration: none;
color: var(--accent-color);
border-bottom: 1.5px solid var(--accent-low-opacity);
padding: 0px ;
}
code {
background-color: var(--grey-one);
border-radius: 8px;
padding: 0.2rem 0.5rem;
font-size: 0.8rem;
font-family: var(--mono-font);
font-weight: 300;
flex-wrap: wrap;
line-height: 1.25rem;
}
pre code {
font-size: 0.75rem;
background-color: var(--grey-six);
white-space: pre;
display: block;
flex-wrap: wrap;
padding: 0.5rem 1rem;
margin: 1rem 0;
}
h5 {
margin-bottom: 0.5rem;
}
h5 {
color: var(--accent-color);
}
h1, h2, h3, h4, h5 {
margin-bottom: 1rem;
}
h1 {
font-size: 2.25rem;
font-weight: 600;
letter-spacing: -0.02rem;
color: var(--accent-color-two);
border-bottom: 1px solid var(--grey-three);
padding-bottom: 1rem;
margin-bottom: 1rem;
}
h2 {
font-size: 1.5rem;
letter-spacing: -0.02rem;
font-weight: 600;
color: var(--accent-color-two);
border-bottom: 1px solid var(--grey-three);
padding-bottom: 1rem;
margin-top: 2rem;
}
h3 {
margin-top: 1rem;
margin-bottom: 0.5rem;
}
li {
margin-left: 1rem;
margin-bottom: 0.5rem;
}
/* Markup processors output this for bold text, but css spec is goofy aah */
strong {
font-weight: bold;
letter-spacing: 0.01rem;
}
ul {
padding-left: 2rem;
}
}

View File

@ -1,207 +0,0 @@
import { is_tree } from './documentation.shared';
import type { Document, DocsTree, DocsTreeNode, DocumentInfo } from './documentation.shared';
import { browser } from '$app/environment';
import fs, { existsSync as exists } from 'fs';
import path from 'path';
import { marked } from 'marked';
import AsciiDocProcessor from 'asciidoctor';
// This file does not work in a browser.
if (browser) {
throw Error('SvelteKit has skill issues');
}
/// Constants
const supported_formats: Map<string, (markup: string) => Document> = new Map();
supported_formats.set('md', (markup: string) => {
let lines = markup.split('\n');
// Get and remove the first line.
const first_line = lines.splice(0, 1)[0];
// Remove `# `.
const title = first_line.substring(2);
// Convert the rest to html
const content = marked(lines.join('\n'));
return { title, content };
});
const asciidoctor = AsciiDocProcessor();
const adoc_fn = (markup: string) => {
// Get first line.
const first_line = markup.split('\n')[0];
// Remove `= `.
const title = first_line.substring(2);
// Convert it to html. Unlike markdown, we do not need to remove the first title heading.
// NOTE: Maybe consider change the safe mode value.
const content = asciidoctor.convert(markup, { doctype: 'book' }) as string;
return { title, content };
};
supported_formats.set('adoc', adoc_fn);
supported_formats.set('asciidoc', adoc_fn);
const supported_filetypes = [...supported_formats.keys()];
let docs_folder = process.env.REVANCED_DOCS_FOLDER ?? 'testing-docs';
const ignored_items = ['assets'];
/// Utility functions
function is_directory(item: string) {
return fs.lstatSync(item).isDirectory();
}
function get_ext(fname: string) {
// Get extname and remove the first dot.
return path.extname(fname).substring(1);
}
function get_slug_of_node(node: DocsTreeNode): string {
if (is_tree(node)) {
return (node as DocsTree).index.slug;
}
return (node as DocumentInfo).slug;
}
/// Important functions
// Get a document. Returns null if it does not exist.
export function get(slug: string): Document | null {
let target = path.join(docs_folder, slug);
// Handle index (readme) file for folder.
if (exists(target) && is_directory(target)) {
target += '/README';
}
const dir = path.dirname(target);
if (!exists(dir)) {
return null;
}
let full_path: string,
ext: string,
found = false;
// We are looking for the file `${target}.(any_supported_extension)`. Try to find it.
for (const item of fs.readdirSync(dir)) {
full_path = path.join(dir, item);
// Get file extension
ext = get_ext(item);
// Unsupported/unrelated file.
if (!supported_formats.has(ext)) {
continue;
}
const desired_path = `${target}.${ext}`; // Don't grab some other random supported file.
if (!is_directory(full_path) && desired_path == full_path) {
// We found it.
found = true;
break;
}
}
if (!found) {
return null;
}
// Process the file and return.
return supported_formats.get(ext!!)!!(fs.readFileSync(full_path!!, 'utf-8'));
}
// Get file information
function process_file(fname: string): DocumentInfo {
// Remove docs folder prefix and file extension suffix, then split it.
const parts = fname
.substring(`${docs_folder}/`.length, fname.length - (get_ext(fname).length + 1))
.split('/');
// Remove `README` suffix if present.
const last_part_index = parts.length - 1;
if (parts[last_part_index] == 'README') {
parts.pop();
}
const slug = parts.join('/');
const title = get(slug)!!.title;
return { slug, title };
}
// Returns a document tree.
function process_folder(dir: string): DocsTree | null {
let tree: DocsTree = {
index: null as any,
nodes: []
};
// List everything in the directory.
const items = fs.readdirSync(dir);
for (const item of items) {
if (ignored_items.includes(item) || ['.', '_'].includes(item[0])) {
continue;
}
const itemPath = path.join(dir, item);
const is_dir = is_directory(itemPath);
let is_index_file = false;
if (!is_dir) {
// Ignore files we cannot process.
if (!supported_formats.has(get_ext(item))) {
continue;
}
for (const ext of supported_filetypes) {
if (item == `README.${ext}`) {
is_index_file = true;
}
}
}
const node = is_dir ? process_folder(itemPath) : process_file(itemPath);
if (node === null) {
console.error(`The ${itemPath} directory does not have a README/index file! ignoring...`);
continue;
}
if (is_index_file) {
tree.index = node as DocumentInfo;
} else {
tree.nodes.push(node);
}
}
if (tree.index === null) {
return null;
}
// `numeric: true` because we want to be able to specify
// the order if necessary by prepending a number to the file name.
tree.nodes.sort((a, b) =>
get_slug_of_node(a).localeCompare(get_slug_of_node(b), 'en', { numeric: true })
);
return tree;
}
// Returns the document tree.
export function index_content(): DocsTree {
const tree = process_folder(docs_folder);
if (tree === null) {
throw new Error('Root must have index (README) file.');
}
return tree;
}

View File

@ -1,35 +0,0 @@
/// Types
export interface Document {
title: string;
// HTML
content: string;
}
export interface DocumentInfo {
title: string;
slug: string;
}
// A tree representing the `docs` folder.
export interface DocsTree {
// index.whatever
index: DocumentInfo;
// Everything except index.whatever
nodes: DocsTreeNode[];
}
export type DocsTreeNode = DocsTree | DocumentInfo;
/// Functions
export function is_tree(node: DocsTreeNode) {
return Object.prototype.hasOwnProperty.call(node, 'nodes');
}
export function assert_is_info_node(v: DocsTreeNode) {
if (is_tree(v)) {
throw new Error('Value is not an info node.');
}
return v as DocumentInfo;
}

View File

@ -8,6 +8,7 @@
import manager_screenshot from '$images/manager_two.png?format=avif;webp;png&picture';
import Meta from '$lib/components/Meta.svelte';
import { JsonLd } from 'svelte-meta-tags';
import Query from '$lib/components/Query.svelte';
import Button from '$lib/components/Button.svelte';
import Footer from '$layout/Footer/FooterHost.svelte';
@ -44,6 +45,42 @@
</script>
<Meta title="Download" />
<JsonLd
schema={{
'@type': 'MobileApplication',
name: 'ReVanced Manager',
description:
'ReVanced Manager is an Android application that uses ReVanced Patcher to add, remove, and modify existing functionalities in Android applications',
abstract: 'Continuing the legacy of Vanced',
applicationCategory: 'UtilitiesApplication',
applicationSuite: 'ReVanced',
downloadUrl: 'https://revanced.app/download',
maintainer: 'ReVanced',
thumbnailUrl: 'https://revanced.app/manager_two.png',
operatingSystem: 'Android 8',
offers: {
'@type': 'Offer',
price: '0'
},
publisher: {
'@type': 'Organization',
name: 'ReVanced',
url: 'https://revanced.app/',
logo: {
'@type': 'ImageObject',
url: 'https://revanced.app/embed.png'
},
sameAs: [
'https://github.com/revanced',
'https://twitter.com/revancedapp',
'https://revanced.app/discord',
'https://www.reddit.com/r/revancedapp',
'https://t.me/app_revanced',
'https://www.youtube.com/@ReVanced'
]
}
}}
/>
<Dialogue bind:modalOpen={warningDialogue}>
<svelte:fragment slot="title">Warning</svelte:fragment>
@ -52,7 +89,7 @@
<Query {query} let:data>
<Button
type="text"
href={data.assets[0].url}
href={data.assets[0].browser_download_url}
download
on:click={() => (warningDialogue = false)}>Okay</Button
>
@ -68,17 +105,17 @@
<Query {query} let:data>
{#if !isAndroid || androidVersion < 8}
<Button on:click={handleClick} type="filled" icon="download">
{data.version}
{data.metadata.tag_name}
</Button>
{:else}
<Button
on:click={handleClick}
type="filled"
icon="download"
href={data.assets[0].url}
href={data.assets[0].browser_download_url}
download
>
{data.version}
{data.metadata.tag_name}
</Button>
{/if}
</Query>

View File

@ -1,6 +1,8 @@
<script lang="ts">
import { building } from '$app/environment';
import { fly } from 'svelte/transition';
import { quintOut } from 'svelte/easing';
import { derived, readable, type Readable } from 'svelte/store';
import { page } from '$app/stores';
import type { Patch } from '$lib/types';
@ -9,6 +11,7 @@
import { queries } from '$data/api';
import Meta from '$lib/components/Meta.svelte';
import { JsonLd } from 'svelte-meta-tags';
import PackageMenu from './PackageMenu.svelte';
import Package from './Package.svelte';
import PatchItem from './PatchItem.svelte';
@ -20,8 +23,15 @@
const query = createQuery(['patches'], queries.patches);
$: selectedPkg = $page.url.searchParams.get('pkg');
let searchTerm = $page.url.searchParams.get('s');
let searchParams: Readable<URLSearchParams>;
if (building) {
searchParams = readable(new URLSearchParams());
} else {
searchParams = derived(page, ($page) => $page.url.searchParams);
}
$: selectedPkg = $searchParams.get('pkg');
let searchTerm = $searchParams.get('s');
let searchTermFiltered = searchTerm
?.replace(/\./g, '')
.replace(/\s/g, '')
@ -30,6 +40,7 @@
let timeout: ReturnType<typeof setTimeout>;
let mobilePackages = false;
let showAllVersions = false;
function checkCompatibility(patch: Patch, pkg: string) {
if (pkg === '') {
@ -95,6 +106,32 @@
</script>
<Meta title="Patches" />
<JsonLd
schema={{
'@context': 'https://schema.org',
'@type': 'WebPage',
name: 'ReVanced Patches',
abstract: 'A list of ReVanced Patches',
breadcrumb: 'Home > Patches',
publisher: {
'@type': 'Organization',
name: 'ReVanced',
url: 'https://revanced.app/',
logo: {
'@type': 'ImageObject',
url: 'https://revanced.app/embed.png'
},
sameAs: [
'https://github.com/revanced',
'https://twitter.com/revancedapp',
'https://revanced.app/discord',
'https://www.reddit.com/r/revancedapp',
'https://t.me/app_revanced',
'https://www.youtube.com/@ReVanced'
]
}
}}
/>
<div class="search">
<div class="search-contain">
@ -160,7 +197,7 @@
<!-- Trigger new animations when package or search changes (I love Svelte) -->
{#key selectedPkg || searchTermFiltered}
<div in:fly={{ y: 10, easing: quintOut, duration: 750 }}>
<PatchItem {patch} />
<PatchItem {patch} bind:showAllVersions />
</div>
{/key}
{/each}

View File

@ -1 +0,0 @@
export const prerender = false;

View File

@ -2,9 +2,11 @@
import { slide, fade } from 'svelte/transition';
import { quintOut } from 'svelte/easing';
import type { Patch } from '$lib/types';
import { friendlyName } from '$util/friendlyName';
import { compare, coerce } from 'semver';
import Button from '$lib/components/Button.svelte';
export let patch: Patch;
export let showAllVersions: boolean;
const hasPatchOptions = !!patch.options.length;
let expanded: boolean = false;
</script>
@ -21,7 +23,7 @@
<h3>{patch.name}</h3>
</div>
{#if hasPatchOptions}
<img id="arrow" src="/icons/arrow.svg" alt="dropdown" />
<img class="expand-arrow" src="/icons/expand_more.svg" alt="dropdown" />
{/if}
</div>
<h5>{patch.description}</h5>
@ -36,13 +38,6 @@
</a>
{/each}
<!-- should i hardcode this to get the version of the first package? idk you cant stop me -->
{#if patch.compatiblePackages.length && patch.compatiblePackages[0].versions.length}
<li class="patch-info">
🎯 {patch.compatiblePackages[0].versions.slice(-1)}
</li>
{/if}
{#if !patch.compatiblePackages.length}
<li class="patch-info">🌎 Universal patch</li>
{/if}
@ -50,6 +45,40 @@
{#if hasPatchOptions}
<li class="patch-info">⚙️ Patch options</li>
{/if}
<!-- should i hardcode this to get the version of the first package? idk you cant stop me -->
{#if patch.compatiblePackages.length && patch.compatiblePackages[0].versions.length}
{#if showAllVersions}
{#each patch.compatiblePackages[0].versions
.slice()
.sort((a, b) => {
const coercedA = coerce(a);
const coercedB = coerce(b);
if (coercedA && coercedB) return compare(coercedA, coercedB);
else if (!coercedA && !coercedB) return 0;
else return !coercedA ? 1 : -1;
})
.reverse() as version}
<li class="patch-info">
🎯 {version}
</li>
{/each}
{:else}
<li class="patch-info">
🎯 {patch.compatiblePackages[0].versions.slice(-1)}
</li>
{/if}
{#if patch.compatiblePackages[0].versions.length > 1}
<Button type="text" on:click={() => (showAllVersions = !showAllVersions)}>
<img
class="expand-arrow"
style:transform={showAllVersions ? 'rotate(90deg)' : 'rotate(-90deg)'}
src="/icons/expand_more.svg"
alt="dropdown"
/>
</Button>
{/if}
{/if}
</ul>
{#if expanded && hasPatchOptions}
@ -78,6 +107,9 @@
}
.patch-info {
display: flex;
justify-content: center;
align-items: center;
list-style: none;
font-size: 0.8rem;
font-weight: 500;
@ -134,13 +166,13 @@
justify-content: space-between;
}
#arrow {
height: 1.5rem;
.expand-arrow {
transition: all 0.2s var(--bezier-one);
user-select: none;
height: 1.5rem;
}
.rotate #arrow {
.rotate .expand-arrow {
transform: rotate(180deg);
}

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="#ACC1D2"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M11.29 8.71L6.7 13.3c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L12 10.83l3.88 3.88c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L12.7 8.71c-.38-.39-1.02-.39-1.41 0z"/></svg>

After

Width:  |  Height:  |  Size: 324 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="#ACC1D2"><path d="M24 24H0V0h24v24z" fill="none" opacity=".87"/><path d="M15.88 9.29L12 13.17 8.12 9.29c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41-.39-.38-1.03-.39-1.42 0z"/></svg>

After

Width:  |  Height:  |  Size: 343 B

View File

@ -1,16 +0,0 @@
# Prerequisites
##### docs/prerequisites
<br />
#### Requirements
- ADB
- x86/x86\_64 host architecture
- Zulu JDK 17
- Latest Android SDK if you plan to build the integrations from the source
- The APK file you want to patch (e.g. YouTube v17.36.37 or YouTube Music v5.23.50). If you want to mount patched applications as root, make sure the same version is installed on your device.
<br />
You can continue by either [building everything from source](https://github.com/revanced/revanced-documentation/wiki/Building-from-source) or [downloading the prebuilt packages](https://github.com/revanced/revanced-documentation/wiki/Downloading-prebuilt-packages).

View File

@ -1,19 +0,0 @@
# 🧩 Patching applications
1. Tap the `Patcher` button in the bottom navigation bar.
2. Tap the `Select an application` card.
3. Here, you have the option to choose between selecting an app from on-device or selecting an APK file directly from storage.
* For selecting on-device applications, tap on the desired app from the shown menu. For an app to show up in this list, the app must be already installed on the device.
> **Warning**: This feature is incomplete for non-root users as ReVanced has yet to add split APK support. We suggest you pick your APK from storage for now.
* To select from storage, click on the `Storage` button and select the APK normally through the file picker.
> **Note**: We recommend downloading APK files from [APKMirror](https://www.apkmirror.com/) as a temporary solution as `.apkm` and `.apks` files are not supported at the moment.
* Verify that the selected application is a version supported by ReVanced. [See the list of supported versions for apps here.](https://github.com/revanced/revanced-patches#-patches)
4. After selecting an application, you will be brought back to the `Patcher` screen again. Tap the `Select patches` card.
5. Select your desired patches. Note that certain patches are required for non-root installations. (e.g. *MicroG Support* patch for YouTube)
6. Tap the `Done` button.
7. After selecting your patches, you will be brought back to the `Patcher` screen again. Tap the `Patch` button.
8. The app is now patching. This process can range from 2-10 minutes depending on your device. Refrain from closing the Manager.
9. When patching is complete, tap on the `Install` button. You may also tap on the three vertical dots in the top right to share logs or the patched APK.
> **Warning**: If you close the Manager after patching, the patched APK file will be **automatically deleted from your device**!
## ⏭️ Whats next
The next section will guide you through managing your installed patched applications.

View File

@ -1,16 +0,0 @@
# Prerequisites
##### docs/prerequisites
<br />
#### Requirements
- ADB
- x86/x86\_64 host architecture
- Zulu JDK 17
- Latest Android SDK if you plan to build the integrations from the source
- The APK file you want to patch (e.g. YouTube v17.36.37 or YouTube Music v5.23.50). If you want to mount patched applications as root, make sure the same version is installed on your device.
<br />
You can continue by either [building everything from source](https://github.com/revanced/revanced-documentation/wiki/Building-from-source) or [downloading the prebuilt packages](https://github.com/revanced/revanced-documentation/wiki/Downloading-prebuilt-packages).

View File

@ -1,243 +0,0 @@
# 🔎 Fingerprinting
Fingerprinting is the process of creating uniquely identifyable data about something arbitrarily large. In the context of ReVanced, fingerprinting is essential to be able to find classes, methods and fields without knowing their original names or certain other attributes, which would be used to identify them under normal circumstances.
## ⛳️ Example fingerprint
This page works with the following fingerprint as an example:
```kt
package app.revanced.patches.ads.fingerprints
// Imports
object LoadAdsFingerprint : MethodFingerprint(
returnType = "Z",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("Z"),
opcodes = listOf(Opcode.RETURN),
strings = listOf("pro"),
customFingerprint = { it.definingClass == "Lcom/some/app/ads/Loader;"}
)
```
## 🆗 Understanding the example fingerprint
The example fingerprint called `LoadAdsFingerprint` which extends on [`MethodFingerprint`](https://github.com/revanced/revanced-patcher/blob/main/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt#L28) is made to uniquely identify a certain method by capturing various attributes of the method such as the return type, access flags, an opcode pattern and more. The following code can be inferred just from the fingerprint:
```kt
package com.some.app.ads
// Imports
4 <attributes> class Loader {
5 public final Boolean <methodName>(<field>: Boolean) {
// ...
8 val userStatus = "pro";
// ...
12 return <returnValue>
}
}
```
## 🚀 How it works
Each attribute of the fingerprint is responsible to describe a specific but distinct part of the method. The combination out of those should be and ideally remain unique to all methods in all classes. In the case of the example fingerprint, the `customFingerprint` attribute is responsible to find the class the method is defined in. This greatly increases the uniqueness of the fingerprint, because now the possible methods reduce down to that class. Adding the signature of the method and a string the method implementation refers to in combination now creates a unique fingerprint in the current example:
- Package & class (Line 4)
```kt
customFingerprint = { it.definingClass == "Lcom/some/app/ads/Loader;"}
```
- Method signature (Line 5)
```kt
returnType = "Z",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("Z"),
```
- Method implementation (Line 8 & 12)
```kt
strings = listOf("pro"),
opcodes = listOf(Opcode.RETURN)
```
## 🔨 How to use fingerprints
After creating a fingerprint, add it to the constructor of the `BytecodePatch`:
```kt
class DisableAdsPatch : BytecodePatch(
listOf(LoadAdsFingerprint)
) { /* .. */ }
```
The ReVanced patcher will try to [resolve the fingerprint](https://github.com/revanced/revanced-patcher/blob/main/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt#L63) **before** it calls the `execute` method of the patch.
The fingerprint can now be used in the patch by accessing [`MethodFingerprint.result`](https://github.com/revanced/revanced-patcher/blob/d2f91a8545567429d64a1bcad6ca1dab62ec95bf/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt#L227):
```kt
class DisableAdsPatch : BytecodePatch(
listOf(LoadAdsFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
val result = LoadAdsFingerprint.result
?: return PatchResultError("LoadAdsFingerprint not found")
// ...
}
}
```
> **Note**: `MethodFingerprint.result` **can be null** if the fingerprint does not match any method. In such case, the fingerprint needs to be fixed and made more resilient if the error is caused by a later version of an app which the fingerprint was not tested on. A fingerprint is good, if it is _light_, but still resilient - like Carbon fiber-reinforced polymers.
If the fingerprint resolved to a method, the following properties are now available:
```kt
data class MethodFingerprintResult(
val method: Method,
val classDef: ClassDef,
val scanResult: MethodFingerprintScanResult,
// ...
) {
val mutableClass
val mutableMethod
// ...
}
```
> Details on how to use them in a patch and what exactly these are will be introduced properly later on this page.
## 🏹 Different ways to resolve a fingerprint
Usually, fingerprints are mostly resolved by the patcher, but it is also possible to manually resolve a fingerprint in a patch. This can be quite useful in lots of situations. To resolve a fingerprint you need a context to resolve it on. The context contains classes and thus methods to which the fingerprint can be resolved against. Example: _You have a fingerprint which you manually want to resolve **without** the help of the patcher._
> **Note**: A fingerprint should not be added to the constructor of `BytecodePatch` if manual resolution is intended, because the patcher would try resolve it before manual resolution.
- On a **list of classes** using [`MethodFingerprint.resolve`](https://github.com/revanced/revanced-patcher/blob/main/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt#L49)
This can be useful, if a fingerprint should be resolved to a smaller subset of classes, otherwise the fingerprint can be resolved by the patcher automatically.
```kt
class DisableAdsPatch : BytecodePatch(
/* listOf(LoadAdsFingerprint) */
) {
override fun execute(context: BytecodeContext): PatchResult {
val result = LoadAdsFingerprint.also { it.resolve(context, context.classes) }.result
?: return PatchResultError("LoadAdsFingerprint not found")
// ...
}
}
```
- On a **single class** using [`MethodFingerprint.resolve`](https://github.com/revanced/revanced-patcher/blob/main/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt#L63)
Sometimes you know a class but you need certain methods. In such case, you can resolve fingerprints on a class.
```kt
class DisableAdsPatch : BytecodePatch(
listOf(LoadAdsFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
val adsLoaderClass = context.classes.single { it.name == "Lcom/some/app/ads/Loader;" }
val result = LoadAdsFingerprint.also { it.resolve(context, adsLoaderClass) }.result
?: return PatchResultError("LoadAdsFingerprint not found")
// ...
}
}
```
- On a **method** using [`MethodFingerprint.resolve`](https://github.com/revanced/revanced-patcher/blob/main/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt#L78)
Resolving a fingerprint on a method is mostly only useful if the fingerprint is used to resolve certain information about a method such as `MethodFingerprintResult.scanResult`. Example: _A fingerprint should be used to resolve the method which loads ads. For that the fingerprint is added to the constructor of `BytecodePatch`. An additional fingerprint is responsible for finding the indices of the instructions with certain string references in the implementation of the method the first fingerprint resolved to._
```kt
class DisableAdsPatch : BytecodePatch(
/* listOf(LoadAdsFingerprint) */
) {
override fun execute(context: BytecodeContext): PatchResult {
// Make sure this fingerprint succeeds as the result is required
val adsFingerprintResult = LoadAdsFingerprint.result
?: return PatchResultError("LoadAdsFingerprint not found")
// Additional fingerprint to get the indices of two strings
val proStringsFingerprint = object : MethodFingerprint(
strings = listOf("free", "trial")
) {}
proStringsFingerprint.also {
// Resolve the fingerprint on the first fingerprints method
it.resolve(context, adsFingerprintResult.method)
}.result?.let { result ->
// Use the fingerprints result
result.scanResult.stringsScanResult!!.matches.forEach { match ->
println("The index of the string '${match.string}' is {match.index}")
}
} ?: return PatchResultError("pro strings fingerprint not found")
return PatchResultSuccess
}
}
```
## 🎯 The result of a fingerprint
After a `MethodFingerprint` resolves successfully, its result can be used. The result contains mutable and immutable references to the method and the class it is defined in.
> **Warning**: By default the immutable references **should be used** to prevent a mutable copy of the immutable references. For a patch to properly use a fingerprint though, usually write access is required. For that the mutable references can be used.
Among them, the result also contains [MethodFingerprintResult.scanResult](https://github.com/revanced/revanced-patcher/blob/main/src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt#L239) which contains additional useful properties:
```kt
data class MethodFingerprintScanResult(
val patternScanResult: PatternScanResult?,
val stringsScanResult: StringsScanResult?
) {
data class PatternScanResult(
val startIndex: Int,
val endIndex: Int,
var warnings: List<Warning>? = null
)
data class StringsScanResult(val matches: List<StringMatch>){
data class StringMatch(val string: String, val index: Int)
}
// ...
}
```
The following properties are utilized by bytecode patches:
- The `MethodFingerprint.strings` allows patches to know the indices of the instructions which hold references to the strings.
- If a fingerprint defines `MethodFingerprint.opcodes`, the start and end index of the first instructions matching that pattern will be available. These are useful to patch the implementation of methods relative to the pattern. Ideally the pattern contains the instructions opcodes pattern which is to be patched, in order to guarantee a successfull patch.
> **Note**: Sometimes long patterns might be necessary, but the bigger the pattern list, the higher the chance it mutates if the app updates. For that reason the annotation `FuzzyPatternScanMethod` can be used on a fingerprint. The `FuzzyPatternScanMethod.threshold` will define, how many opcodes can remain unmatched. `PatternScanResult.warnings` can then be used if necessary, if it is necessary to know where pattern missmatches occured.
## ⭐ Closely related code examples
### 🧩 Patches
- [CommentsPatch](https://github.com/revanced/revanced-patches/blob/main/src/main/kotlin/app/revanced/patches/youtube/layout/comments/bytecode/patch/CommentsPatch.kt)
- [MusicVideoAdsPatch](https://github.com/revanced/revanced-patches/blob/main/src/main/kotlin/app/revanced/patches/music/ad/video/patch/MusicVideoAdsPatch.kt)
### Fingerprints
- [LoadVideoAdsFingerprint](https://github.com/revanced/revanced-patches/blob/main/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/LoadVideoAdsFingerprint.kt)
- [SeekbarTappingParentFingerprint](https://github.com/revanced/revanced-patches/blob/main/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingParentFingerprint.kt)
## ⏭️ Whats next
The next section will give a suggestion on coding conventions and on the file structure of a patch.

View File

@ -1,16 +0,0 @@
# Prerequisites
##### docs/prerequisites
<br />
#### Requirements
- ADB
- x86/x86\_64 host architecture
- Zulu JDK 17
- Latest Android SDK if you plan to build the integrations from the source
- The APK file you want to patch (e.g. YouTube v17.36.37 or YouTube Music v5.23.50). If you want to mount patched applications as root, make sure the same version is installed on your device.
<br />
You can continue by either [building everything from source](https://github.com/revanced/revanced-documentation/wiki/Building-from-source) or [downloading the prebuilt packages](https://github.com/revanced/revanced-documentation/wiki/Downloading-prebuilt-packages).