├── .gitignore ├── LICENSE ├── README.md ├── android ├── .gitignore ├── app │ ├── .gitignore │ ├── build.gradle │ ├── capacitor.build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── getcapacitor │ │ │ └── myapp │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── assets │ │ │ ├── capacitor.config.json │ │ │ └── capacitor.plugins.json │ │ ├── java │ │ │ └── com │ │ │ │ └── wrapped │ │ │ │ └── ytmusic │ │ │ │ └── MainActivity.java │ │ └── res │ │ │ ├── drawable-land-hdpi │ │ │ └── splash.png │ │ │ ├── drawable-land-mdpi │ │ │ └── splash.png │ │ │ ├── drawable-land-xhdpi │ │ │ └── splash.png │ │ │ ├── drawable-land-xxhdpi │ │ │ └── splash.png │ │ │ ├── drawable-land-xxxhdpi │ │ │ └── splash.png │ │ │ ├── drawable-port-hdpi │ │ │ └── splash.png │ │ │ ├── drawable-port-mdpi │ │ │ └── splash.png │ │ │ ├── drawable-port-xhdpi │ │ │ └── splash.png │ │ │ ├── drawable-port-xxhdpi │ │ │ └── splash.png │ │ │ ├── drawable-port-xxxhdpi │ │ │ └── splash.png │ │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── drawable │ │ │ ├── ic_launcher_background.xml │ │ │ └── splash.png │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ ├── ic_launcher_background.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ │ └── xml │ │ │ ├── config.xml │ │ │ └── file_paths.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── getcapacitor │ │ └── myapp │ │ └── ExampleUnitTest.java ├── build.gradle ├── capacitor.settings.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── variables.gradle ├── capacitor.config.json ├── package.json ├── resources ├── icon.png └── splash.png ├── src ├── controls.js ├── index.js └── plugins.js ├── webpack.config.js └── www ├── index.html └── js └── plugins ├── adblock.js ├── audioonly.js ├── background.js ├── config.js ├── controls.js ├── fetch.js ├── mediasession.js ├── swipe.js ├── tracking.js ├── ui.js └── xmlhttprequest.js /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | 19 | .DS_Store 20 | 21 | # Generated by package manager 22 | node_modules/ 23 | 24 | # Generated by Cordova 25 | /plugins/ 26 | /platforms/ 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 4v3ngR 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ytm-wrapped 2 | A simple capacitor app to load yt music and to inject some scripts 3 | 4 | # NOTE!!!!!! 5 | As there are more capable (and native) youtube music players available, I'll not be making any further changes to ytm-wrapped. I recommend ViMusic (https://github.com/vfsfitvnm/ViMusic) for playing youtube music. 6 | 7 | ![Screenshot_20220414_170821](https://user-images.githubusercontent.com/101933870/163352971-58d2b582-797f-4882-9c7a-1b1f36ef96f4.jpeg) 8 | 9 | ## dependencies 10 | capacitor 11 | android cli development tools 12 | 13 | ## building 14 | 15 | ### install dependencies 16 | ```sh 17 | npm install 18 | ``` 19 | 20 | ### debug build (creates an apk ytm-debug.apk) 21 | ```sh 22 | npm run debug 23 | ``` 24 | 25 | ### release (creates an apk ytm-unsigned.apk) 26 | ```sh 27 | npm run release 28 | ``` 29 | 30 | ### signing the apk 31 | This is what I use. You'll need to create an appropriate keystore 32 | ```sh 33 | apksigner sign --ks my.keystore ./ytm-unsigned.apk 34 | ``` 35 | 36 | ## plugins 37 | * plugins are stored in www/js/plugins. They're injected into the browser after the browser has loaded 38 | * the plugin list is in www/js/index.js 39 | 40 | ## XHR/Fetch intercepting 41 | I've added some code that will allow plugins to receive the responses to XMLHttpRequests and Fetch requests. This has allowed a new adblock plugin to be created (it filters out the ad details from the player response). The functionality to intercept the responses, and make changes, should allow for some good plugins. 42 | 43 | ## Releases 44 | Here's the link to the releases page https://github.com/4v3ngR/ytm-wrapped/releases 45 | 46 | ## Notes 47 | * Adblocking now works with XHR interception 48 | * Background works when playing audio. If playing a video, the video will pause. Noting that videos can actually start while the app is in the background 49 | * I'm not an android developer. 50 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | # Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore 2 | 3 | # Built application files 4 | *.apk 5 | *.aar 6 | *.ap_ 7 | *.aab 8 | 9 | # Files for the ART/Dalvik VM 10 | *.dex 11 | 12 | # Java class files 13 | *.class 14 | 15 | # Generated files 16 | bin/ 17 | gen/ 18 | out/ 19 | # Uncomment the following line in case you need and you don't have the release build type files in your app 20 | # release/ 21 | 22 | # Gradle files 23 | .gradle/ 24 | build/ 25 | 26 | # Local configuration file (sdk path, etc) 27 | local.properties 28 | 29 | # Proguard folder generated by Eclipse 30 | proguard/ 31 | 32 | # Log Files 33 | *.log 34 | 35 | # Android Studio Navigation editor temp files 36 | .navigation/ 37 | 38 | # Android Studio captures folder 39 | captures/ 40 | 41 | # IntelliJ 42 | *.iml 43 | .idea/workspace.xml 44 | .idea/tasks.xml 45 | .idea/gradle.xml 46 | .idea/assetWizardSettings.xml 47 | .idea/dictionaries 48 | .idea/libraries 49 | # Android Studio 3 in .gitignore file. 50 | .idea/caches 51 | .idea/modules.xml 52 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 53 | .idea/navEditor.xml 54 | 55 | # Keystore files 56 | # Uncomment the following lines if you do not want to check your keystore files in. 57 | #*.jks 58 | #*.keystore 59 | 60 | # External native build folder generated in Android Studio 2.2 and later 61 | .externalNativeBuild 62 | .cxx/ 63 | 64 | # Google Services (e.g. APIs or Firebase) 65 | # google-services.json 66 | 67 | # Freeline 68 | freeline.py 69 | freeline/ 70 | freeline_project_description.json 71 | 72 | # fastlane 73 | fastlane/report.xml 74 | fastlane/Preview.html 75 | fastlane/screenshots 76 | fastlane/test_output 77 | fastlane/readme.md 78 | 79 | # Version control 80 | vcs.xml 81 | 82 | # lint 83 | lint/intermediates/ 84 | lint/generated/ 85 | lint/outputs/ 86 | lint/tmp/ 87 | # lint/reports/ 88 | 89 | # Android Profiling 90 | *.hprof 91 | 92 | # Cordova plugins for Capacitor 93 | capacitor-cordova-android-plugins 94 | 95 | # Copied web assets 96 | app/src/main/assets/public 97 | -------------------------------------------------------------------------------- /android/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build/* 2 | !/build/.npmkeep 3 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.compileSdkVersion 5 | defaultConfig { 6 | applicationId "com.wrapped.ytmusic" 7 | minSdkVersion rootProject.ext.minSdkVersion 8 | targetSdkVersion rootProject.ext.targetSdkVersion 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 12 | aaptOptions { 13 | // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. 14 | // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61 15 | ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~' 16 | } 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | } 25 | 26 | repositories { 27 | flatDir{ 28 | dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs' 29 | } 30 | } 31 | 32 | dependencies { 33 | implementation fileTree(include: ['*.jar'], dir: 'libs') 34 | implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" 35 | implementation project(':capacitor-android') 36 | testImplementation "junit:junit:$junitVersion" 37 | androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" 38 | androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" 39 | implementation project(':capacitor-cordova-android-plugins') 40 | } 41 | 42 | apply from: 'capacitor.build.gradle' 43 | 44 | try { 45 | def servicesJSON = file('google-services.json') 46 | if (servicesJSON.text) { 47 | apply plugin: 'com.google.gms.google-services' 48 | } 49 | } catch(Exception e) { 50 | logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work") 51 | } 52 | -------------------------------------------------------------------------------- /android/app/capacitor.build.gradle: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN 2 | 3 | android { 4 | compileOptions { 5 | sourceCompatibility JavaVersion.VERSION_1_8 6 | targetCompatibility JavaVersion.VERSION_1_8 7 | } 8 | } 9 | 10 | apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" 11 | dependencies { 12 | implementation project(':capacitor-app') 13 | implementation project(':capacitor-music-controls-plugin-new') 14 | 15 | } 16 | 17 | 18 | if (hasProperty('postBuildExtras')) { 19 | postBuildExtras() 20 | } 21 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.getcapacitor.myapp; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import android.content.Context; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | import androidx.test.platform.app.InstrumentationRegistry; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * @see Testing documentation 15 | */ 16 | @RunWith(AndroidJUnit4.class) 17 | public class ExampleInstrumentedTest { 18 | 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 23 | 24 | assertEquals("com.getcapacitor.app", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 33 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /android/app/src/main/assets/capacitor.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "appId": "com.wrapped.ytmusic", 3 | "appName": "ytm-wrapped", 4 | "webDir": "www", 5 | "bundledWebRuntime": false, 6 | "cordova": { 7 | "preferences": { 8 | "overrideUserAgent": "Mozilla/5.0 (Linux; Android 7.1.1; SM-T555 Build/NMF26X; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.96 Safari/537.36" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /android/app/src/main/assets/capacitor.plugins.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "pkg": "@capacitor/app", 4 | "classpath": "com.capacitorjs.plugins.app.AppPlugin" 5 | }, 6 | { 7 | "pkg": "capacitor-music-controls-plugin-new", 8 | "classpath": "com.ingageco.capacitormusiccontrols.CapacitorMusicControls" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/wrapped/ytmusic/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.wrapped.ytmusic; 2 | 3 | import com.getcapacitor.BridgeActivity; 4 | 5 | public class MainActivity extends BridgeActivity {} 6 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-land-hdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/drawable-land-hdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-land-mdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/drawable-land-mdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-land-xhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/drawable-land-xhdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-land-xxhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/drawable-land-xxhdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-land-xxxhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/drawable-land-xxxhdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-port-hdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/drawable-port-hdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-port-mdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/drawable-port-mdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-port-xhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/drawable-port-xhdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-port-xxhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/drawable-port-xxhdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-port-xxxhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/drawable-port-xxxhdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/drawable/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFF 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ytm-wrapped 4 | ytm-wrapped 5 | com.wrapped.ytmusic 6 | com.wrapped.ytmusic 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 17 | 18 | 19 | 22 | -------------------------------------------------------------------------------- /android/app/src/main/res/xml/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/app/src/main/res/xml/file_paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.getcapacitor.myapp; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | 14 | @Test 15 | public void addition_isCorrect() throws Exception { 16 | assertEquals(4, 2 + 2); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:4.2.1' 11 | classpath 'com.google.gms:google-services:4.3.5' 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | apply from: "variables.gradle" 19 | 20 | allprojects { 21 | repositories { 22 | google() 23 | jcenter() 24 | } 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /android/capacitor.settings.gradle: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN 2 | include ':capacitor-android' 3 | project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') 4 | 5 | include ':capacitor-app' 6 | project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android') 7 | 8 | include ':capacitor-music-controls-plugin-new' 9 | project(':capacitor-music-controls-plugin-new').projectDir = new File('../node_modules/capacitor-music-controls-plugin-new/android') 10 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | 19 | # AndroidX package structure to make it clearer which packages are bundled with the 20 | # Android operating system, and which are packaged with your app's APK 21 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 22 | android.useAndroidX=true 23 | # Automatically convert third-party libraries to use AndroidX 24 | android.enableJetifier=true 25 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | include ':capacitor-cordova-android-plugins' 3 | project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/') 4 | 5 | apply from: 'capacitor.settings.gradle' -------------------------------------------------------------------------------- /android/variables.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | minSdkVersion = 21 3 | compileSdkVersion = 30 4 | targetSdkVersion = 30 5 | androidxActivityVersion = '1.2.0' 6 | androidxAppCompatVersion = '1.2.0' 7 | androidxCoordinatorLayoutVersion = '1.1.0' 8 | androidxCoreVersion = '1.3.2' 9 | androidxFragmentVersion = '1.3.0' 10 | junitVersion = '4.13.1' 11 | androidxJunitVersion = '1.1.2' 12 | androidxEspressoCoreVersion = '3.3.0' 13 | cordovaAndroidVersion = '7.0.0' 14 | } -------------------------------------------------------------------------------- /capacitor.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "appId": "com.wrapped.ytmusic", 3 | "appName": "ytm-wrapped", 4 | "webDir": "www", 5 | "bundledWebRuntime": false, 6 | "cordova": { 7 | "preferences": { 8 | "overrideUserAgent": "Mozilla/5.0 (Linux; Android 7.1.1; SM-T555 Build/NMF26X; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.96 Safari/537.36" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ytm-wrapped", 3 | "version": "0.1.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "setup": "[ -d 'android' ] || npx cap add android", 8 | "resources": "capacitor-resources -p android", 9 | "build": "npm run setup && npm run resources && webpack -c webpack.config.js && npx cap sync", 10 | "debug": "npm run build && cd android && ./gradlew assembleDebug && cp app/build/outputs/apk/debug/app-debug.apk ../ytm-debug.apk", 11 | "release": "npm run build && cd android && ./gradlew assembleRelease && cp app/build/outputs/apk/release/app-release-unsigned.apk ../ytm-unsigned.apk" 12 | }, 13 | "author": "4v3ngR", 14 | "license": "MIT", 15 | "dependencies": { 16 | "@capacitor-mobi/cordova-plugin-inappbrowser": "^5.0.3", 17 | "@capacitor/android": "^3.4.3", 18 | "@capacitor/app": "^1.1.1", 19 | "@capacitor/cli": "^3.4.3", 20 | "@capacitor/core": "^3.4.3", 21 | "capacitor-music-controls-plugin-new": "github:4v3ngR/capacitor-music-controls-plugin-new", 22 | "capacitor-resources": "^2.0.5", 23 | "webpack": "^5.70.0", 24 | "webpack-cli": "^4.9.2" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/resources/icon.png -------------------------------------------------------------------------------- /resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4v3ngR/ytm-wrapped/d25e16f39e2540a07d909ff3aa721754f826ebc7/resources/splash.png -------------------------------------------------------------------------------- /src/controls.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | const { Plugins } = require('@capacitor/core'); 3 | const { CapacitorMusicControls } = Plugins; 4 | 5 | let inAppBrowserRef = null; 6 | let createdMusicControls = false; 7 | 8 | function createMusicControls(data) { 9 | if (!data) data = {}; 10 | const { 11 | title = '', 12 | artist = '', 13 | image = '', 14 | playing = false, 15 | duration = 0 16 | } = data; 17 | 18 | if (!duration) return; 19 | 20 | const [ a, b ] = artist.split('•'); 21 | const metadata = { 22 | track: title ? title : '', 23 | cover: image ? image : '', 24 | album: b ? b : '', 25 | artist: a ? a : '', 26 | ticker: 'YouTube music - wrapped for you', 27 | hasPrev: true, 28 | hasNext: true, 29 | hasClose: false, 30 | isPlaying: playing, 31 | dismissable: false, 32 | playIcon: 'media_play', 33 | pauseIcon: 'media_pause', 34 | prevIcon: 'media_prev', 35 | nextIcon: 'media_next', 36 | closeIcon: 'media_close', 37 | notificationIcon: 'notification', 38 | duration: (duration ? duration : 0) * 1000, 39 | iconsColor: -1 40 | }; 41 | 42 | if (createdMusicControls) { 43 | CapacitorMusicControls.updateMetadata(metadata, () => null, () => null); 44 | } else { 45 | CapacitorMusicControls.create(metadata, () => null, () => null); 46 | CapacitorMusicControls.addListener('controlsNotification', events); 47 | } 48 | createdMusicControls = true; 49 | } 50 | 51 | function events(action) { 52 | const message = action.message; 53 | switch(message) { 54 | case 'music-controls-next': 55 | case 'music-controls-media-button-next': 56 | inAppBrowserRef.executeScript({code: "window.controls.next();"}, () => null); 57 | break; 58 | case 'music-controls-previous': 59 | case 'music-controls-media-button-previous': 60 | inAppBrowserRef.executeScript({code: "window.controls.prev();"}, () => null); 61 | break; 62 | case 'music-controls-pause': 63 | case 'music-controls-headset-unplugged': 64 | inAppBrowserRef.executeScript({code: "window.controls.pause();"}, () => null); 65 | break; 66 | case 'music-controls-play': 67 | case 'music-controls-headset-plugged': 68 | inAppBrowserRef.executeScript({code: "window.controls.play();"}, () => null); 69 | break; 70 | case 'music-controls-toggle-play-pause': 71 | case 'music-controls-media-button-play-pause': 72 | inAppBrowserRef.executeScript({code: "window.controls.playpause();"}, () => null); 73 | break; 74 | } 75 | } 76 | 77 | function handleIABMessage(e) { 78 | let obj = e.data; 79 | if (obj.message) { 80 | switch (obj.message) { 81 | case "play": 82 | case "timeupdate": 83 | if (createdMusicControls) { 84 | CapacitorMusicControls.updateState({ isPlaying: true, elapsed: obj.elapsed * 1000 }); 85 | } 86 | break; 87 | case "pause": 88 | if (createdMusicControls) { 89 | CapacitorMusicControls.updateState({ isPlaying: false, elapsed: obj.elapsed * 1000 }); 90 | } 91 | break; 92 | case "loadeddata": 93 | createMusicControls(obj); 94 | break; 95 | } 96 | } 97 | } 98 | 99 | exports = module.exports = { 100 | close: () => { 101 | inAppBrowserRef.removeEventListener("message", handleIABMessage); 102 | CapacitorMusicControls.removeAllListeners(); 103 | CapacitorMusicControls.destroy(); 104 | createdMusicControls = null; 105 | inAppBrowserRef = null; 106 | }, 107 | init: (ref) => { 108 | inAppBrowserRef = ref; 109 | ref.addEventListener("message", handleIABMessage); 110 | } 111 | }; 112 | })(); 113 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | const { App } = require("@capacitor/app"); 2 | const { loadPlugins, injectPlugins } = require("./plugins"); 3 | const controls = require("./controls"); 4 | 5 | let ref = null; 6 | 7 | App.addListener('appStateChange', async ({ isActive }) => { 8 | if (ref) { 9 | ref.executeScript( 10 | { 11 | code: `window.postMessage({ message: 'statechanged', active: ${isActive}});` 12 | }, 13 | () => null 14 | ); 15 | } 16 | }); 17 | 18 | const setStatus = (text) => { 19 | const splash = document.querySelector('#status'); 20 | if (splash) { 21 | splash.innerText = text; 22 | } 23 | } 24 | 25 | const loadstopHandler = () => { 26 | ref.insertCSS({code:"body{background-color:black;}"}); 27 | try { 28 | injectPlugins(ref, "loadstop"); 29 | } catch (ex) { 30 | console.error("got ex", ex.message); 31 | } 32 | ref.show(); 33 | controls.init(ref); 34 | } 35 | 36 | const loadstartHandler = () => { 37 | try { 38 | injectPlugins(ref, "loadstart"); 39 | } catch (ex) { 40 | console.error("got ex", ex.message); 41 | } 42 | } 43 | 44 | const exitHandler = () => { 45 | setStatus("exiting..."); 46 | App.exitApp(); 47 | } 48 | 49 | const loadYTM = async () => { 50 | if (!ref) { 51 | ref = cordova.InAppBrowser.open( 52 | 'https://music.youtube.com/?source=pwa', 53 | '_blank', 54 | 'location=no,hidden=true,hardwareback=yes' 55 | ); 56 | 57 | ref.addEventListener('loadstart', loadstartHandler); 58 | ref.addEventListener('loadstop', loadstopHandler); 59 | ref.addEventListener('exit', exitHandler); 60 | } 61 | } 62 | 63 | const main = async () => { 64 | await loadPlugins(); 65 | loadYTM(); 66 | } 67 | 68 | main(); 69 | -------------------------------------------------------------------------------- /src/plugins.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | const plugins = { 3 | "fetch.js": { 4 | "src": null, 5 | "stage": "loadstart" 6 | }, 7 | "xmlhttprequest.js": { 8 | "src": null, 9 | "stage": "loadstart" 10 | }, 11 | "mediasession.js": { 12 | "src": null, 13 | "stage": "loadstart" 14 | }, 15 | "tracking.js": { 16 | "src": null, 17 | "stage": "loadstop" 18 | }, 19 | "background.js": { 20 | "src": null, 21 | "stage": "loadstop" 22 | }, 23 | "adblock.js": { 24 | "src": null, 25 | "stage": "loadstop" 26 | }, 27 | "audioonly.js": { 28 | "src": null, 29 | "stage": "loadstop" 30 | }, 31 | "ui.js": { 32 | "src": null, 33 | "stage": "loadstop" 34 | }, 35 | "controls.js": { 36 | "src": null, 37 | "stage": "loadstop" 38 | }, 39 | "config.js": { 40 | "src": null, 41 | "stage": "loadstop" 42 | }, 43 | "swipe.js": { 44 | "src": null, 45 | "stage": "loadstop" 46 | } 47 | }; 48 | 49 | const loadPlugin = async (plugin) => { 50 | const x = await fetch(`js/plugins/${plugin}`); 51 | const script = await x.text(); 52 | plugins[plugin].src = script; 53 | }; 54 | 55 | const loadPlugins = async () => { 56 | const keys = Object.keys(plugins); 57 | for (let i = 0; i < keys.length; i++) { 58 | await loadPlugin(keys[i]); 59 | } 60 | }; 61 | 62 | const injectPlugin = (ref, plugin, stage) => { 63 | const script = plugins[plugin]; 64 | if (script && script.stage === stage) { 65 | ref.executeScript({code: script.src}, () => null); 66 | } 67 | }; 68 | 69 | const injectPlugins = (ref, stage) => { 70 | Object.keys(plugins).forEach((plugin) => injectPlugin(ref, plugin, stage)); 71 | }; 72 | 73 | exports = module.exports = { loadPlugins, injectPlugins }; 74 | })(); 75 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = { 4 | mode: 'production', 5 | entry: './src/index.js', 6 | output: { 7 | path: path.resolve(__dirname, 'www/js'), 8 | filename: '[name].js' 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 29 | 30 | 31 | 32 |
33 |
34 |
Loading YouTube Music...
35 |
36 |
37 | 38 | 39 | -------------------------------------------------------------------------------- /www/js/plugins/adblock.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | if (window.adblock === "loaded") return; 3 | 4 | window.adblock = "loaded"; 5 | console.log("loading adblock"); 6 | 7 | function interceptXHR(state, url, data) { 8 | if (url.includes('youtubei/v1/player') && state === 'response') try { 9 | var obj = JSON.parse(data); 10 | if (obj.adPlacements) { 11 | delete obj.adPlacements; 12 | data = JSON.stringify(obj); 13 | } 14 | return data; 15 | } catch (ex) { 16 | } 17 | 18 | if (state === 'open' && data) { 19 | if ( 20 | url.includes('youtubei/v1/log_event') || 21 | url.includes('play.google.com') || 22 | url.includes('api/stats/atr') || 23 | url.includes('doubleclick.net') 24 | ) { 25 | return false; 26 | } 27 | } 28 | 29 | return data; 30 | } 31 | 32 | if (XMLHttpRequest.addXHRInterceptor) { 33 | XMLHttpRequest.addXHRInterceptor(interceptXHR); 34 | } 35 | })(); 36 | -------------------------------------------------------------------------------- /www/js/plugins/audioonly.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | if (window.audioonly === "loaded") return; 3 | window.audioonly = "loaded"; 4 | console.log("loading audioonly"); 5 | 6 | function getBestThumbnail(thumbnails) { 7 | let res = { sizes: "1" }; 8 | for (let i = 0; i < thumbnails.length; i++) { 9 | if (parseInt(thumbnails[i].sizes, 10) > parseInt(res.sizes, 10)) { 10 | res = thumbnails[i]; 11 | } 12 | } 13 | return res; 14 | } 15 | 16 | window.addEventListener("mediahaschanged", (e) => { 17 | const thumbnail = getBestThumbnail(navigator.mediaSession.metadata.artwork); 18 | if (thumbnail) { 19 | const player = document.querySelector("ytmusic-player"); 20 | if (player) { 21 | let cover = player.querySelector("img#cover-image"); 22 | if (!cover) { 23 | const img = player.querySelector("img#img"); 24 | if (img) { 25 | cover = document.createElement("img"); 26 | cover.setAttribute("id", "cover-image"); 27 | cover.setAttribute("class", "style-scope yt-img-shadow"); 28 | cover.setAttribute("style", "height: 100%; object-fit: scale-down;"); 29 | img.parentNode.replaceChild(cover, img); 30 | } 31 | } 32 | 33 | if (cover) cover.setAttribute("src", thumbnail.src); 34 | 35 | const content = document.querySelector('div.content'); 36 | if (content) { 37 | let background = document.querySelector('div#background-image'); 38 | if (!background) { 39 | background = document.createElement('div'); 40 | background.setAttribute("id", "background-image"); 41 | background.setAttribute("class", "background-image"); 42 | content.setAttribute("style", "background: transparent"); 43 | content.parentNode.insertBefore(background, content); 44 | } 45 | if (background) { 46 | background.setAttribute("style", `background-image: url('${thumbnail.src}'); background-position: center;`); 47 | } 48 | } 49 | 50 | player.removeAttribute("video-mode_"); 51 | } 52 | } 53 | }); 54 | 55 | function forceAudioOnly(state, url, data) { 56 | if (url.includes('youtubei/v1/player') && state === 'response') try { 57 | var obj = JSON.parse(data); 58 | if (obj.videoDetails) { 59 | obj.videoDetails.musicVideoType = "MUSIC_VIDEO_TYPE_ATV"; 60 | data = JSON.stringify(obj); 61 | } 62 | return data; 63 | } catch (ex) {} 64 | return data; 65 | } 66 | 67 | if (XMLHttpRequest.addXHRInterceptor) { 68 | XMLHttpRequest.addXHRInterceptor(forceAudioOnly); 69 | } 70 | })(); 71 | -------------------------------------------------------------------------------- /www/js/plugins/background.js: -------------------------------------------------------------------------------- 1 | // original code from "Video Background Play Fix" a Firefox extension 2 | // By JanH (https://addons.mozilla.org/en-US/firefox/user/11797710) 3 | // Thanks for releasing it MIT 4 | 5 | (function() { 6 | Object.defineProperties(document, 7 | { 8 | 'hidden': {value: false}, 9 | 'webkitHidden': {value: false}, 10 | 'visibilityState': {value: 'visible'}, 11 | 'webkitVisibilityState': {value: 'visible'}, 12 | } 13 | ); 14 | 15 | window.navigator.getBattery = async () => { 16 | return { 17 | charging: true, 18 | chargingTime: 0, 19 | discargeTime: Infinity, 20 | level: 1, 21 | onchargingchange: null, 22 | onchargingtimechange: null, 23 | ondiscargingtimechange: null, 24 | onlevelchange: null, 25 | superfunhappyslide: true 26 | } 27 | }; 28 | 29 | window.addEventListener('visibilitychange', evt => { 30 | evt.stopImmediatePropagation(); 31 | return false; 32 | }, true); 33 | 34 | window.addEventListener('webkitvisibilitychange', evt => { 35 | evt.stopImmediatePropagation(); 36 | return false; 37 | }, true); 38 | 39 | window.addEventListener('blur', evt => { 40 | evt.stopImmediatePropagation(); 41 | window.dispatchEvent(new Event('focus')); 42 | return false; 43 | }, true); 44 | 45 | loop(pressKey, 60 * 1000, 10 * 1000); 46 | 47 | function pressKey() { 48 | const keyCodes = [18]; 49 | let key = keyCodes[getRandomInt(0, keyCodes.length)]; 50 | sendKeyEvent("keydown", key); 51 | sendKeyEvent("keyup", key); 52 | } 53 | 54 | function sendKeyEvent (aEvent, aKey) { 55 | document.dispatchEvent(new KeyboardEvent(aEvent, { 56 | bubbles: true, 57 | cancelable: true, 58 | keyCode: aKey, 59 | which: aKey, 60 | })); 61 | } 62 | 63 | function loop(aCallback, aDelay, aJitter) { 64 | let jitter = getRandomInt(-aJitter/2, aJitter/2); 65 | let delay = Math.max(aDelay + jitter, 0); 66 | window.setTimeout(() => { 67 | aCallback(); 68 | loop(aCallback, aDelay, aJitter); 69 | }, delay); 70 | } 71 | 72 | function getRandomInt(aMin, aMax) { 73 | let min = Math.ceil(aMin); 74 | let max = Math.floor(aMax); 75 | return Math.floor(Math.random() * (max - min)) + min; 76 | } 77 | })(); 78 | -------------------------------------------------------------------------------- /www/js/plugins/config.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | if (!window.configInterval) { 3 | window.configInterval = setInterval(function() { 4 | try { 5 | window.yt.config_.IS_SUBSCRIBER = true; 6 | window.yt.config_.AUDIO_QUALITY = "AUDIO_QUALITY_HIGH"; 7 | clearInterval(window.configInterval); 8 | window.configInterval = null; 9 | } catch (ex) {} 10 | }, 100); 11 | } 12 | })(); 13 | -------------------------------------------------------------------------------- /www/js/plugins/controls.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | let thumbnail = null; 3 | let elapsed = 0; 4 | let duration = 0; 5 | 6 | var video = null; 7 | var player = document.querySelector('ytmusic-player'); 8 | if (player) { 9 | video = player.querySelector('video'); 10 | if (video) { 11 | if (video.paused) { 12 | handlePause(null); 13 | } else { 14 | handlePlay(null); 15 | } 16 | if (video.duration) { 17 | dispatch('loadeddata'); 18 | } 19 | 20 | if (!video.eventsAdded) { 21 | video.addEventListener("play", handlePlay); 22 | video.addEventListener("pause", handlePause); 23 | video.addEventListener("timeupdate", handleTimeUpdate); 24 | video.eventsAdded = true; 25 | } 26 | } 27 | } 28 | 29 | function getBestThumbnail(thumbnails) { 30 | let res = { sizes: "1" }; 31 | for (let i = 0; i < thumbnails.length; i++) { 32 | if (parseInt(thumbnails[i].sizes, 10) > parseInt(res.sizes, 10)) { 33 | res = thumbnails[i]; 34 | } 35 | } 36 | return res; 37 | } 38 | 39 | window.addEventListener("mediahaschanged", (e) => { 40 | thumbnail = getBestThumbnail(navigator.mediaSession.metadata.artwork).src; 41 | dispatch("loadeddata"); 42 | }); 43 | 44 | function handleTimeUpdate(e) { 45 | dispatch("timeupdate"); 46 | } 47 | 48 | function handlePlay(e) { 49 | dispatch("play"); 50 | } 51 | 52 | function handlePause(e) { 53 | dispatch("pause"); 54 | } 55 | 56 | function dispatch(message) { 57 | slider = document.querySelector('tp-yt-paper-slider#progress-bar'); 58 | if (slider) { 59 | duration = parseInt(slider.getAttribute("aria-valuemax"), 10); 60 | elapsed = parseInt(slider.getAttribute("aria-valuenow"), 10); 61 | } 62 | 63 | const { state, meta } = navigator.mediaSession; 64 | if (meta) { 65 | const { album, artist, title } = meta; 66 | webkit.messageHandlers.cordova_iab.postMessage(JSON.stringify( 67 | { 68 | message, 69 | image: thumbnail, 70 | album, 71 | artist, 72 | title, 73 | playing: state === "playing", 74 | elapsed, 75 | duration 76 | } 77 | )); 78 | } 79 | } 80 | 81 | // add global functions to allow the cordova app to control the video 82 | window.controls = { 83 | play: function() { 84 | if (video) { 85 | video.play(); 86 | } 87 | }, 88 | pause: function() { 89 | if (video) { 90 | video.pause(); 91 | } 92 | }, 93 | next: function() { 94 | var button = document.querySelector("tp-yt-paper-icon-button.next-button"); 95 | if (button) button.click(); 96 | }, 97 | prev: function() { 98 | var button = document.querySelector("tp-yt-paper-icon-button.previous-button"); 99 | if (button) button.click(); 100 | }, 101 | playpause: function() { 102 | if (video) { 103 | if (video.paused) video.play(); 104 | else video.pause(); 105 | } 106 | } 107 | } 108 | })(); 109 | -------------------------------------------------------------------------------- /www/js/plugins/fetch.js: -------------------------------------------------------------------------------- 1 | // original code https://github.com/github/fetch MIT licensed 2 | (function() { 3 | if (window.fetched === "loaded") return; 4 | 5 | console.log("loading fetch"); 6 | window.fetched = "loaded"; 7 | 8 | // these functions will be provided the response body and will 9 | // return an updated response body 10 | window.fetchInterceptors = []; 11 | 12 | var support = { 13 | searchParams: 'URLSearchParams' in window, 14 | iterable: 'Symbol' in window && 'iterator' in Symbol, 15 | blob: false, 16 | formData: 'FormData' in window, 17 | arrayBuffer: 'ArrayBuffer' in window 18 | } 19 | 20 | function isDataView(obj) { 21 | return obj && DataView.prototype.isPrototypeOf(obj) 22 | } 23 | 24 | if (support.arrayBuffer) { 25 | var viewClasses = [ 26 | '[object Int8Array]', 27 | '[object Uint8Array]', 28 | '[object Uint8ClampedArray]', 29 | '[object Int16Array]', 30 | '[object Uint16Array]', 31 | '[object Int32Array]', 32 | '[object Uint32Array]', 33 | '[object Float32Array]', 34 | '[object Float64Array]' 35 | ] 36 | 37 | var isArrayBufferView = 38 | ArrayBuffer.isView || 39 | function(obj) { 40 | return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 41 | } 42 | } 43 | 44 | function normalizeName(name) { 45 | if (typeof name !== 'string') { 46 | name = String(name) 47 | } 48 | if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') { 49 | throw new TypeError('Invalid character in header field name: "' + name + '"') 50 | } 51 | return name.toLowerCase() 52 | } 53 | 54 | function normalizeValue(value) { 55 | if (typeof value !== 'string') { 56 | value = String(value) 57 | } 58 | return value 59 | } 60 | 61 | // Build a destructive iterator for the value list 62 | function iteratorFor(items) { 63 | var iterator = { 64 | next: function() { 65 | var value = items.shift() 66 | return {done: value === undefined, value: value} 67 | } 68 | } 69 | 70 | if (support.iterable) { 71 | iterator[Symbol.iterator] = function() { 72 | return iterator 73 | } 74 | } 75 | 76 | return iterator 77 | } 78 | 79 | function Headers(headers) { 80 | this.map = {} 81 | 82 | if (headers instanceof Headers) { 83 | headers.forEach(function(value, name) { 84 | this.append(name, value) 85 | }, this) 86 | } else if (Array.isArray(headers)) { 87 | headers.forEach(function(header) { 88 | this.append(header[0], header[1]) 89 | }, this) 90 | } else if (headers) { 91 | Object.getOwnPropertyNames(headers).forEach(function(name) { 92 | this.append(name, headers[name]) 93 | }, this) 94 | } 95 | } 96 | 97 | Headers.prototype.append = function(name, value) { 98 | name = normalizeName(name) 99 | value = normalizeValue(value) 100 | var oldValue = this.map[name] 101 | this.map[name] = oldValue ? oldValue + ', ' + value : value 102 | } 103 | 104 | Headers.prototype['delete'] = function(name) { 105 | delete this.map[normalizeName(name)] 106 | } 107 | 108 | Headers.prototype.get = function(name) { 109 | name = normalizeName(name) 110 | return this.has(name) ? this.map[name] : null 111 | } 112 | 113 | Headers.prototype.has = function(name) { 114 | return this.map.hasOwnProperty(normalizeName(name)) 115 | } 116 | 117 | Headers.prototype.set = function(name, value) { 118 | this.map[normalizeName(name)] = normalizeValue(value) 119 | } 120 | 121 | Headers.prototype.forEach = function(callback, thisArg) { 122 | for (var name in this.map) { 123 | if (this.map.hasOwnProperty(name)) { 124 | callback.call(thisArg, this.map[name], name, this) 125 | } 126 | } 127 | } 128 | 129 | Headers.prototype.keys = function() { 130 | var items = [] 131 | this.forEach(function(value, name) { 132 | items.push(name) 133 | }) 134 | return iteratorFor(items) 135 | } 136 | 137 | Headers.prototype.values = function() { 138 | var items = [] 139 | this.forEach(function(value) { 140 | items.push(value) 141 | }) 142 | return iteratorFor(items) 143 | } 144 | 145 | Headers.prototype.entries = function() { 146 | var items = [] 147 | this.forEach(function(value, name) { 148 | items.push([name, value]) 149 | }) 150 | return iteratorFor(items) 151 | } 152 | 153 | if (support.iterable) { 154 | Headers.prototype[Symbol.iterator] = Headers.prototype.entries 155 | } 156 | 157 | function consumed(body) { 158 | if (body.bodyUsed) { 159 | return Promise.reject(new TypeError('Already read')) 160 | } 161 | body.bodyUsed = true 162 | } 163 | 164 | function fileReaderReady(reader) { 165 | return new Promise(function(resolve, reject) { 166 | reader.onload = function() { 167 | resolve(reader.result) 168 | } 169 | reader.onerror = function() { 170 | reject(reader.error) 171 | } 172 | }) 173 | } 174 | 175 | function readBlobAsArrayBuffer(blob) { 176 | var reader = new FileReader() 177 | var promise = fileReaderReady(reader) 178 | reader.readAsArrayBuffer(blob) 179 | return promise 180 | } 181 | 182 | function readBlobAsText(blob) { 183 | var reader = new FileReader() 184 | var promise = fileReaderReady(reader) 185 | reader.readAsText(blob) 186 | return promise 187 | } 188 | 189 | function readArrayBufferAsText(buf) { 190 | var view = new Uint8Array(buf) 191 | var chars = new Array(view.length) 192 | 193 | for (var i = 0; i < view.length; i++) { 194 | chars[i] = String.fromCharCode(view[i]) 195 | } 196 | return chars.join('') 197 | } 198 | 199 | function bufferClone(buf) { 200 | if (buf.slice) { 201 | return buf.slice(0) 202 | } else { 203 | var view = new Uint8Array(buf.byteLength) 204 | view.set(new Uint8Array(buf)) 205 | return view.buffer 206 | } 207 | } 208 | 209 | function interceptBody(text) { 210 | for (var i = 0; i < window.fetchInterceptors.length; i++) { 211 | text = window.fetchInterceptors[i](text); 212 | } 213 | return text; 214 | } 215 | 216 | function Body() { 217 | this.bodyUsed = false 218 | 219 | this._initBody = function(body) { 220 | /* 221 | fetch-mock wraps the Response object in an ES6 Proxy to 222 | provide useful test harness features such as flush. However, on 223 | ES5 browsers without fetch or Proxy support pollyfills must be used; 224 | the proxy-pollyfill is unable to proxy an attribute unless it exists 225 | on the object before the Proxy is created. This change ensures 226 | Response.bodyUsed exists on the instance, while maintaining the 227 | semantic of setting Request.bodyUsed in the constructor before 228 | _initBody is called. 229 | */ 230 | this.bodyUsed = this.bodyUsed 231 | this._bodyInit = body 232 | if (!body) { 233 | this._bodyText = '' 234 | } else if (typeof body === 'string') { 235 | this._bodyText = body 236 | } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { 237 | this._bodyBlob = body 238 | } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { 239 | this._bodyFormData = body 240 | } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { 241 | this._bodyText = body.toString() 242 | } else if (support.arrayBuffer && support.blob && isDataView(body)) { 243 | this._bodyArrayBuffer = bufferClone(body.buffer) 244 | // IE 10-11 can't handle a DataView body. 245 | this._bodyInit = new Blob([this._bodyArrayBuffer]) 246 | } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { 247 | this._bodyArrayBuffer = bufferClone(body) 248 | } else { 249 | this._bodyText = body = Object.prototype.toString.call(body) 250 | } 251 | 252 | if (!this.headers.get('content-type')) { 253 | if (typeof body === 'string') { 254 | this.headers.set('content-type', 'text/plain;charset=UTF-8') 255 | } else if (this._bodyBlob && this._bodyBlob.type) { 256 | this.headers.set('content-type', this._bodyBlob.type) 257 | } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { 258 | this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8') 259 | } 260 | } 261 | } 262 | 263 | if (support.blob) { 264 | this.blob = function() { 265 | var rejected = consumed(this) 266 | if (rejected) { 267 | return rejected 268 | } 269 | 270 | if (this._bodyBlob) { 271 | return Promise.resolve(this._bodyBlob) 272 | } else if (this._bodyArrayBuffer) { 273 | return Promise.resolve(new Blob([this._bodyArrayBuffer])) 274 | } else if (this._bodyFormData) { 275 | throw new Error('could not read FormData body as blob') 276 | } else { 277 | return Promise.resolve(new Blob([this._bodyText])) 278 | } 279 | } 280 | 281 | this.arrayBuffer = function() { 282 | if (this._bodyArrayBuffer) { 283 | var isConsumed = consumed(this) 284 | if (isConsumed) { 285 | return isConsumed 286 | } 287 | if (ArrayBuffer.isView(this._bodyArrayBuffer)) { 288 | return Promise.resolve( 289 | this._bodyArrayBuffer.buffer.slice( 290 | this._bodyArrayBuffer.byteOffset, 291 | this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength 292 | ) 293 | ) 294 | } else { 295 | return Promise.resolve(this._bodyArrayBuffer) 296 | } 297 | } else { 298 | return this.blob().then(readBlobAsArrayBuffer) 299 | } 300 | } 301 | } 302 | 303 | this.text = function() { 304 | var rejected = consumed(this) 305 | if (rejected) { 306 | return rejected 307 | } 308 | 309 | if (this._bodyBlob) { 310 | return readBlobAsText(this._bodyBlob) 311 | } else if (this._bodyArrayBuffer) { 312 | return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) 313 | } else if (this._bodyFormData) { 314 | throw new Error('could not read FormData body as text') 315 | } else { 316 | return Promise.resolve(interceptBody(this._bodyText)) 317 | } 318 | } 319 | 320 | if (support.formData) { 321 | this.formData = function() { 322 | return this.text().then(decode) 323 | } 324 | } 325 | 326 | this.json = function() { 327 | return this.text().then(JSON.parse) 328 | } 329 | 330 | return this 331 | } 332 | 333 | // HTTP methods whose capitalization should be normalized 334 | var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'] 335 | 336 | function normalizeMethod(method) { 337 | var upcased = method.toUpperCase() 338 | return methods.indexOf(upcased) > -1 ? upcased : method 339 | } 340 | 341 | function Request(input, options) { 342 | if (!(this instanceof Request)) { 343 | throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.') 344 | } 345 | 346 | options = options || {} 347 | var body = options.body 348 | 349 | if (input instanceof Request) { 350 | if (input.bodyUsed) { 351 | throw new TypeError('Already read') 352 | } 353 | this.url = input.url 354 | this.credentials = input.credentials 355 | if (!options.headers) { 356 | this.headers = new Headers(input.headers) 357 | } 358 | this.method = input.method 359 | this.mode = input.mode 360 | this.signal = input.signal 361 | if (!body && input._bodyInit != null) { 362 | body = input._bodyInit 363 | input.bodyUsed = true 364 | } 365 | } else { 366 | this.url = String(input) 367 | } 368 | 369 | this.credentials = options.credentials || this.credentials || 'same-origin' 370 | if (options.headers || !this.headers) { 371 | this.headers = new Headers(options.headers) 372 | } 373 | this.method = normalizeMethod(options.method || this.method || 'GET') 374 | this.mode = options.mode || this.mode || null 375 | this.signal = options.signal || this.signal || (function () { 376 | if ('AbortController' in window) { 377 | var ctrl = new AbortController(); 378 | return ctrl.signal; 379 | } 380 | }()); 381 | this.referrer = null 382 | 383 | if ((this.method === 'GET' || this.method === 'HEAD') && body) { 384 | throw new TypeError('Body not allowed for GET or HEAD requests') 385 | } 386 | this._initBody(body) 387 | 388 | if (this.method === 'GET' || this.method === 'HEAD') { 389 | if (options.cache === 'no-store' || options.cache === 'no-cache') { 390 | // Search for a '_' parameter in the query string 391 | var reParamSearch = /([?&])_=[^&]*/ 392 | if (reParamSearch.test(this.url)) { 393 | // If it already exists then set the value with the current time 394 | this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime()) 395 | } else { 396 | // Otherwise add a new '_' parameter to the end with the current time 397 | var reQueryString = /\?/ 398 | this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime() 399 | } 400 | } 401 | } 402 | } 403 | 404 | Request.prototype.clone = function() { 405 | return new Request(this, {body: this._bodyInit}) 406 | } 407 | 408 | function decode(body) { 409 | var form = new FormData() 410 | body 411 | .trim() 412 | .split('&') 413 | .forEach(function(bytes) { 414 | if (bytes) { 415 | var split = bytes.split('=') 416 | var name = split.shift().replace(/\+/g, ' ') 417 | var value = split.join('=').replace(/\+/g, ' ') 418 | form.append(decodeURIComponent(name), decodeURIComponent(value)) 419 | } 420 | }) 421 | return form 422 | } 423 | 424 | function parseHeaders(rawHeaders) { 425 | var headers = new Headers() 426 | // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space 427 | // https://tools.ietf.org/html/rfc7230#section-3.2 428 | var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ') 429 | // Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill 430 | // https://github.com/github/fetch/issues/748 431 | // https://github.com/zloirock/core-js/issues/751 432 | preProcessedHeaders 433 | .split('\r') 434 | .map(function(header) { 435 | return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header 436 | }) 437 | .forEach(function(line) { 438 | var parts = line.split(':') 439 | var key = parts.shift().trim() 440 | if (key) { 441 | var value = parts.join(':').trim() 442 | headers.append(key, value) 443 | } 444 | }) 445 | return headers 446 | } 447 | 448 | Body.call(Request.prototype) 449 | 450 | function Response(bodyInit, options) { 451 | if (!(this instanceof Response)) { 452 | throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.') 453 | } 454 | if (!options) { 455 | options = {} 456 | } 457 | 458 | this.type = 'default' 459 | this.status = options.status === undefined ? 200 : options.status 460 | this.ok = this.status >= 200 && this.status < 300 461 | this.statusText = options.statusText === undefined ? '' : '' + options.statusText 462 | this.headers = new Headers(options.headers) 463 | this.url = options.url || '' 464 | this._initBody(bodyInit) 465 | } 466 | 467 | Body.call(Response.prototype) 468 | 469 | Response.prototype.clone = function() { 470 | return new Response(this._bodyInit, { 471 | status: this.status, 472 | statusText: this.statusText, 473 | headers: new Headers(this.headers), 474 | url: this.url 475 | }) 476 | } 477 | 478 | Response.error = function() { 479 | var response = new Response(null, {status: 0, statusText: ''}) 480 | response.type = 'error' 481 | return response 482 | } 483 | 484 | var redirectStatuses = [301, 302, 303, 307, 308] 485 | 486 | Response.redirect = function(url, status) { 487 | if (redirectStatuses.indexOf(status) === -1) { 488 | throw new RangeError('Invalid status code') 489 | } 490 | 491 | return new Response(null, {status: status, headers: {location: url}}) 492 | } 493 | 494 | var DOMException = window.DOMException 495 | try { 496 | new DOMException() 497 | } catch (err) { 498 | DOMException = function(message, name) { 499 | this.message = message 500 | this.name = name 501 | var error = Error(message) 502 | this.stack = error.stack 503 | } 504 | DOMException.prototype = Object.create(Error.prototype) 505 | DOMException.prototype.constructor = DOMException 506 | } 507 | 508 | function fetch(input, init) { 509 | return new Promise(function(resolve, reject) { 510 | var request = new Request(input, init) 511 | 512 | if (request.signal && request.signal.aborted) { 513 | return reject(new DOMException('Aborted', 'AbortError')) 514 | } 515 | 516 | var xhr = new XMLHttpRequest() 517 | 518 | function abortXhr() { 519 | xhr.abort() 520 | } 521 | 522 | xhr.onload = function() { 523 | var options = { 524 | status: xhr.status, 525 | statusText: xhr.statusText, 526 | headers: parseHeaders(xhr.getAllResponseHeaders() || '') 527 | } 528 | options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL') 529 | var body = 'response' in xhr ? xhr.response : xhr.responseText 530 | setTimeout(function() { 531 | resolve(new Response(body, options)) 532 | }, 0) 533 | } 534 | 535 | xhr.onerror = function() { 536 | setTimeout(function() { 537 | reject(new TypeError('Network request failed')) 538 | }, 0) 539 | } 540 | 541 | xhr.ontimeout = function() { 542 | setTimeout(function() { 543 | reject(new TypeError('Network request failed')) 544 | }, 0) 545 | } 546 | 547 | xhr.onabort = function() { 548 | setTimeout(function() { 549 | reject(new DOMException('Aborted', 'AbortError')) 550 | }, 0) 551 | } 552 | 553 | function fixUrl(url) { 554 | try { 555 | return url === '' && window.location.href ? window.location.href : url 556 | } catch (e) { 557 | return url 558 | } 559 | } 560 | 561 | xhr.open(request.method, fixUrl(request.url), true) 562 | 563 | if (request.credentials === 'include') { 564 | xhr.withCredentials = true 565 | } else if (request.credentials === 'omit') { 566 | xhr.withCredentials = false 567 | } 568 | 569 | if ('responseType' in xhr) { 570 | if (support.blob) { 571 | xhr.responseType = 'blob' 572 | } else if ( 573 | support.arrayBuffer && 574 | request.headers.get('Content-Type') && 575 | request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1 576 | ) { 577 | xhr.responseType = 'arraybuffer' 578 | } 579 | } 580 | 581 | if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) { 582 | Object.getOwnPropertyNames(init.headers).forEach(function(name) { 583 | xhr.setRequestHeader(name, normalizeValue(init.headers[name])) 584 | }) 585 | } else { 586 | request.headers.forEach(function(value, name) { 587 | xhr.setRequestHeader(name, value) 588 | }) 589 | } 590 | 591 | if (request.signal) { 592 | request.signal.addEventListener('abort', abortXhr) 593 | 594 | xhr.onreadystatechange = function() { 595 | // DONE (success or failure) 596 | if (xhr.readyState === 4) { 597 | request.signal.removeEventListener('abort', abortXhr) 598 | } 599 | } 600 | } 601 | 602 | xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit) 603 | }) 604 | } 605 | 606 | fetch.interceptors = []; 607 | fetch.addInterceptor = function(fn) { 608 | if (fetch.interceptors.includes(fn)) return; 609 | fetch.interceptors.push(fn); 610 | } 611 | 612 | fetch.removeInterceptor = function(fn) { 613 | var index = fetch.interceptors.indexOf(fn); 614 | if (index !== -1) { 615 | fetch.interceptors.splice(index, 1); 616 | } 617 | } 618 | 619 | fetch.polyfill = true 620 | window.fetch = fetch 621 | window.Headers = Headers 622 | window.Request = Request 623 | window.Response = Response 624 | })(); 625 | -------------------------------------------------------------------------------- /www/js/plugins/mediasession.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | class MediaSession { 3 | constructor() { 4 | this.meta = null; 5 | this.state = "none"; 6 | this.actionHandlers = {}; 7 | this.position = 0; 8 | this.duration = 0; 9 | } 10 | 11 | get playbackState() { 12 | return this.state; 13 | } 14 | 15 | get positionState() { 16 | return { 17 | position: this.position, 18 | duration: this.duration, 19 | playbackRate: 1.0 20 | } 21 | } 22 | 23 | set positionState(dict) { 24 | console.log("setPositionState called", dict); 25 | if (dict) { 26 | this.position = dict.position; 27 | this.duration = dict.duration; 28 | } 29 | } 30 | 31 | set playbackState(newstate) { 32 | this.state = newstate; 33 | } 34 | 35 | setActionHandler = (type, callback) => { 36 | this.actionHandlers[type] = callback; 37 | } 38 | 39 | get metadata() { 40 | return this.meta; 41 | } 42 | 43 | set metadata(m) { 44 | this.meta = m; 45 | window.dispatchEvent(new Event("mediahaschanged")); 46 | } 47 | } 48 | 49 | class MediaMetadata { 50 | constructor(metadata) { 51 | this.metadata = metadata; 52 | } 53 | 54 | get title() { 55 | return this.metadata.title; 56 | } 57 | 58 | set title(t) { 59 | this.metadata.title = t; 60 | } 61 | 62 | get artist() { 63 | return this.metadata.artist; 64 | } 65 | 66 | set artist(a) { 67 | this.metadata.artist = a; 68 | } 69 | 70 | get album() { 71 | return this.metadata.album; 72 | } 73 | 74 | set album(a) { 75 | this.metadata.album = a; 76 | } 77 | 78 | get artwork() { 79 | return this.metadata.artwork; 80 | } 81 | 82 | set artwork(a) { 83 | this.metadata.artwork = a; 84 | } 85 | } 86 | 87 | if (!navigator.mediaSession) { 88 | navigator.mediaSession = new MediaSession(); 89 | } 90 | 91 | window.MediaMetadata = MediaMetadata; 92 | })(); 93 | -------------------------------------------------------------------------------- /www/js/plugins/swipe.js: -------------------------------------------------------------------------------- 1 | // based on https://gist.github.com/SleepWalker/da5636b1abcbaff48c4d 2 | (function() { 3 | let touchstartX = 0; 4 | let touchstartY = 0; 5 | let touchendX = 0; 6 | let touchendY = 0; 7 | 8 | const threshold = 8; 9 | 10 | if (window.swipeloaded === true) return; 11 | window.swipeloaded = true; 12 | 13 | const handleGesture = (touchstartX, touchstartY, touchendX, touchendY) => { 14 | const delx = touchendX - touchstartX; 15 | const dely = touchendY - touchstartY; 16 | 17 | if(Math.abs(delx) > Math.abs(dely)){ 18 | if (delx > threshold) return "right"; 19 | else if (delx < threshold) return "left"; 20 | } 21 | else if(Math.abs(delx) < Math.abs(dely)){ 22 | if (dely > threshold) return "down"; 23 | else if (dely < threshold) return "up"; 24 | } 25 | else return "tap"; 26 | } 27 | 28 | let swiping = false; 29 | const handleTouchStart = (event) => { 30 | if (swiping === false) { 31 | swiping = true; 32 | touchstartX = event.changedTouches[0].screenX; 33 | touchstartY = event.changedTouches[0].screenY; 34 | } 35 | event.stopPropagation(); 36 | event.preventDefault(); 37 | } 38 | 39 | const handleTouchEnd = (event) => { 40 | event.stopPropagation(); 41 | event.preventDefault(); 42 | 43 | if (swiping === true) { 44 | touchendX = event.changedTouches[0].screenX; 45 | touchendY = event.changedTouches[0].screenY; 46 | const direction = handleGesture(touchstartX, touchstartY, touchendX, touchendY); 47 | swiping = false; 48 | 49 | let button = null; 50 | switch (direction) { 51 | case 'left': 52 | button = document.querySelector("tp-yt-paper-icon-button.next-button"); 53 | if (button) button.click(); 54 | break; 55 | case 'right': 56 | const video = document.querySelector('video'); 57 | if (video) video.currentTime = 0; 58 | setTimeout(() => { 59 | button = document.querySelector("tp-yt-paper-icon-button.previous-button"); 60 | if (button) button.click(); 61 | }, 500); 62 | break; 63 | default: 64 | return; 65 | } 66 | 67 | const cover = player.querySelector("img#cover-image"); 68 | if (cover) { 69 | cover.setAttribute("src", "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mN8XA8AAksBZG7LpHYAAAAASUVORK5CYII="); 70 | } 71 | } 72 | } 73 | 74 | const player = document.querySelector('ytmusic-player'); 75 | if (player) { 76 | player.removeEventListener('touchstart', handleTouchStart); 77 | player.removeEventListener('touchend', handleTouchEnd); 78 | player.addEventListener('touchstart', handleTouchStart); 79 | player.addEventListener('touchend', handleTouchEnd); 80 | } 81 | })(); 82 | -------------------------------------------------------------------------------- /www/js/plugins/tracking.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | if (Image.hooked) return; 3 | Image.hooked = true; 4 | 5 | function setSrc(src) { 6 | // block tracking urls through images 7 | if (src.includes("music.youtube.com/api/stats")) { 8 | src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdjYGRkYAAAAAwAA7JK5lUAAAAASUVORK5CYII="; 9 | } 10 | 11 | this.setAttribute("src", src); 12 | } 13 | 14 | function getSrc() { 15 | return this.getAttribute("src"); 16 | } 17 | 18 | Object.defineProperty(Image.prototype, 'src', { 19 | get: getSrc, 20 | set: setSrc, 21 | configurable: true 22 | }); 23 | 24 | navigator.sendBeacon = function(url, data) { 25 | // do nothing 26 | return true; 27 | } 28 | })(); 29 | -------------------------------------------------------------------------------- /www/js/plugins/ui.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | const iconData = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAA3XAAAN1wFCKJt4AAAG20lEQVR42u1aa0hVWRT+rlcNS+k2Mj18JL3fVNiglr1To2CoqQaiH1ZMU432gCYqiBrsAZFaGVRDBQX+iSl/DIE9KLOs0UlrKoqmKHszFVNjPlJ8fPNjHTle7zn3nns95+ow94PNPuy99t5rfWc/195AAAEEEEAAAQTwf4XNH40Q6AtgBoAEAMMBDAQQCSBcEakB8DeApwAeAigFUGQD/vrPMksgksBaAjcJ0MfwO4E1FLL+M4bHENhPoLYDhrcPNQT2EYjuyoaHEFhHoNpEw9uHWgI/EejW1YwfRuAPCw1vH24TGNpVjF/g0193OMj+/SU4HL6Q8InA/M42fimBRo/K2u1kWhqZm0uWlZFVVXRBVZXkZWeTKSlSxjMJTQRWdZbxKz0q2KsXuW0b+eYNvcbr1+TWrUZ7x5rO6PZNbv94Zib58aNqUHMzef06mZVFLlhAxseTAwdKiI8nFy4kd+wgb9wgW1rUch8+kKtXk0FBnnrCPH8ZP5hAla4yUVFkUZFqwOfP5N69MtaNju+4ODInh6yvV+u5eJHs08dduWrKJstS40PdzvYjR5IvX6pKnzxJxsb6PtvHxZH5+Wp9z5+Tw4e7K3OLQIiVBGzWbXzECPL9e/WvL1li3NAZM8hz58jUVO389HS1N7x7Rw4d6q6+H60yPlrZkbk22rs3+eKFqmBCgnd/urBQyl6+rC+TlKQSXFlJRka6Gwr9rCBgv2aDNht5/rwoVl9PTprkfVe/dEnKl5S4l5s8mWxoENmzZ6VtbdkcKw422nv75cvVMbpihW9j3SgBALl0qdqe/jCrMfUApZzqXBvq0YN8+1aUOX3aNX/jRrK21jMx3hAAkKdOifybN2RYmJ5chpkEaB9p168XRRobtSem0lLJLyw0l4CYGJloSTIjQ0+uzIhtQQaM7wcgXjNzlbILPX4cePRIw91ic47NwqtXwIkT8r16tZ7UVwT6dJgAANM1PUcTJgDDhsn34cPGlQ8OBsaNA+x2D5oFiVyIzrJ+9KjEo0YBY8fqebummUFAgmZqSorEjx4Bd+4YJ+DgQeD2bSA3173cnj0id+SIdv6tW8DTp866uCLRDAK0t5dJSRJfueJd9x09WuIxYzouV1Qk8cSJehLDzCBgsGbqiBES370rcWoqcOaMDA2rEB8PFBRIWwBw757yi3SPAEM8jkgDzTo0U6OiJH7+XOKsLCAhAWhpARYtsoaATZuA+fOBmBjgwgWgslLSo6O9093LHhDukmK3A2Fh8l1dLXG3bs6xFQgNdW7j0ydFw3C9lSbCDAJc0dIiK23rbN1ZCA521cdLGNG+xnVzQKBGSXY41NWgbWwFHj92bqO17dae4IpqMwj4qJnaOvYHDZJ42TJgyhRg82brCNiyRdpIT1emZ2V+fvZMr8Q/ZhDwRDP1/n11ZgaAujrg2jWgqcl9bY2NzrE3ck1N0kZdnXPbDx7o9hkzCHiomXr1qrJPnO55V9cWOTlihKeN0IED0sbevfrjf5qy0Ssu1qvlTzMOQos1DxsDBqjOy5QU7QNJWZnknztn7mEIIGfPVp2t+m63b83oAZeFh3aorARKSuR7wwb/rwCZmepO9OVLnX+H4g4TYAPeAijX7aYAkJYGzJzpmt86O+vP0r4hIQGYM8dZB1eUKbqb4g9Yo9nFgoLIO3ekK1ZUkMHBro7S3btluJg1BEJCyPJykS8vd+cW+8Fsl5i2QzQ5WZ0L8vKsd4kdOqSO/cRE/7jEFBL26SqVna366VautI6Atv7HXbvcyWb71y0eEiIu7Vb3mL6bSjscPy5l8/P1ZdaulbpJ8sIF1+HmfGvc16q7gU26CvbsSd68qf6hI0eEGCMEdO9Ozp0rTtb2eaGh5LFjar1lZWREhLv6rFuSlFcgt3Qbj4iQO7xW3L1LTpvm+9XYrFnk/ftqfYWFZHi4uzIVll6NGboctdvJnTvJpiZV8eJicvFi+dOejO7RQ/z9166p5Rsbye3bPb0ZqKYBD5CW49AXEuYD+AWA/h54/HggLw9ITlbTGhqA0lLx9T15ovoSIiLkYDN+vKzxbX0KxcXAunWe/I7NAL6xAb/6bSNG4HvDF58FBc5X3Z5QXy8XLVOnGhkqLQS+89UOWwdJWArgqCHXmsMhB6fkZGDkSCA2Vjw5gPgWXryQU11JiTg7q6qMqNAMIMMG/NxpThkC85Slh34OVQS+RlcAgSFuVwfzQwX1vNWdSEKw8lDykx8eSoaiq4JAPwK5urtG35/K5li2w7OIiEgCmQRKlZnaW6NbCPxGIIPAF1bp6a/n8r0hl6yJkKu2AQC+hPNz+fcAKuH8XP4dAggggAACCCCAACzCv/e8u6T2f9nCAAAAAElFTkSuQmCC"; 3 | 4 | const pictures = document.querySelectorAll("picture.ytmusic-nav-bar"); 5 | for (let i = 0; i < pictures.length; i++) { 6 | const img = document.createElement("img"); 7 | img.setAttribute("src", iconData); 8 | img.setAttribute("width", "32"); 9 | img.setAttribute("height", "32"); 10 | pictures[i].replaceChildren(img); 11 | } 12 | 13 | const initStaticStyle = () => { 14 | let upsell = document.querySelector('ytmusic-pivot-bar-item-renderer[tab-id="SPunlimited"]'); 15 | if (upsell) { 16 | upsell.setAttribute("style", "visibility: hidden !important; display: none !important;"); 17 | } 18 | 19 | let signin = document.querySelector('a.sign-in-link.style-scope.ytmusic-nav-bar'); 20 | if (signin) { 21 | signin.setAttribute("style", "padding: 0px 4px 0px 4px;border-radius: 20px;"); 22 | signin.innerHTML = ''; 23 | } 24 | 25 | document.querySelectorAll("style").forEach(style => { 26 | let text = style.innerHTML; 27 | style.innerHTML = text.replace(/935px/g, '617px').replace(/936px/g, '618px'); 28 | }); 29 | 30 | let styleTag = document.querySelector("style#staticStyles"); 31 | if (styleTag) return; 32 | 33 | styleTag = document.createElement("style"); 34 | styleTag.setAttribute("id", "staticStyles"); 35 | 36 | let css = ` 37 | * { 38 | outline: none !important; 39 | } 40 | .next-items-button, 41 | .previous-items-button { 42 | visibility: hidden !important; 43 | display: none !important; 44 | } 45 | ytmusic-av-toggle, 46 | ytmusic-mealbar-promo-renderer { 47 | visibility: hidden !important; 48 | display: none !important; 49 | } 50 | div#extraControls { 51 | position: relative; 52 | padding-top: 16px; 53 | left: 0px; 54 | right: 0px; 55 | height: 32px; 56 | overflow: hidden; 57 | display: flex; 58 | } 59 | tp-yt-paper-slider { 60 | width: calc(100% - 100px) !important; 61 | } 62 | ytmusic-like-button-renderer { 63 | display: inherit !important; 64 | } 65 | .dislike, .like { 66 | width: 32px !important; 67 | height: 32px !important; 68 | padding: 4px !important; 69 | } 70 | @media (max-width: 617px) { 71 | ytmusic-player { 72 | animation-duration: 0s !important; 73 | } 74 | tp-yt-paper-icon-button.fullscreen-button { 75 | visibility: hidden !important; 76 | display: none !important; 77 | touch-action: none !important; 78 | } 79 | ytmusic-player:not([player-ui-state_=MINIPLAYER]) div#song-media-controls, 80 | ytmusic-player:not([player-ui-state_=MINIPLAYER]) div#song-image { 81 | background: transparent !important; 82 | position: fixed !important; 83 | left: 0px !important; 84 | top: 16px !important; 85 | width: 100% !important; 86 | height: 56.25vw !important; 87 | padding: 0px !important; 88 | } 89 | div#main-panel { 90 | padding: 0px 84px !important; 91 | } 92 | div.content { 93 | padding-top: 24px !important; 94 | } 95 | ytmusic-app-layout[expanded-controls] div#extraControls { 96 | padding-top: 0px; 97 | position: absolute; 98 | top: 56.25vw; 99 | bottom: 40px; 100 | height: auto; 101 | } 102 | ytmusic-app-layout[expanded-controls] tp-yt-paper-slider { 103 | position: absolute; 104 | height: 32px; 105 | left: 0px; 106 | bottom: 10px; 107 | width: calc(100% - 32px) !important; 108 | } 109 | ytmusic-app-layout[expanded-controls] tp-yt-paper-icon-button#expand-volume { 110 | position: absolute; 111 | right: 10px; 112 | bottom: 10px; 113 | } 114 | ytmusic-app-layout[expanded-controls] tp-yt-paper-icon-button#expand-shuffle { 115 | position: absolute; 116 | top: 219px; 117 | right: 48px; 118 | } 119 | ytmusic-app-layout[expanded-controls] tp-yt-paper-icon-button#expand-repeat { 120 | position: absolute; 121 | top: 219px; 122 | left: 48px; 123 | } 124 | ytmusic-app-layout[expanded-controls] ytmusic-like-button-renderer#like-button-renderer { 125 | position: absolute; 126 | left: 40px; 127 | width: auto; 128 | right: 40px; 129 | top: 92px; 130 | display: flex !important; 131 | flex-direction: row; 132 | justify-content: space-between; 133 | } 134 | ytmusic-app-layout[expanded-controls] div.side-panel { 135 | position: absolute !important; 136 | top: calc(100vh - 207px) !important; 137 | } 138 | ytmusic-app-layout[player-page-open_][expanded-controls] div.left-controls-buttons { 139 | position: fixed; 140 | top: calc(-100vh + 56.25vw + 330px); 141 | left: 80px; 142 | right: 80px; 143 | height: 64px; 144 | display: flex; 145 | flex-direction: row; 146 | justify-content: space-evenly; 147 | } 148 | ytmusic-app-layout[player-page-open_][expanded-controls] tp-yt-paper-icon-button#play-pause-button { 149 | width: 64px; 150 | height: 64px; 151 | } 152 | ytmusic-app-layout[player-page-open_][expanded-controls] tp-yt-paper-slider#progress-bar { 153 | position: fixed; 154 | top: calc(-100vh + 56.25vw + 460px); 155 | width: auto !important; 156 | left: 48px; 157 | right: 48px; 158 | } 159 | ytmusic-app-layout[player-page-open_][expanded-controls] div.content-info-wrapper.style-scope.ytmusic-player-bar { 160 | position: fixed; 161 | top: calc(-100vh + 56.25vw + 215px); 162 | align-items: center; 163 | left: 78px; 164 | right: 66px; 165 | } 166 | ytmusic-app-layout[player-page-open_][expanded-controls] div.middle-controls-buttons { 167 | position: fixed; 168 | left: 8px; 169 | } 170 | } 171 | @media (min-width: 618px) { 172 | div#song-image { 173 | height: 52vh; 174 | padding: 0px !important; 175 | } 176 | div#extraControls { 177 | position: fixed !important; 178 | top: -8px; 179 | padding: 0px; 180 | height: 32px !important; 181 | } 182 | .dislike, .like { 183 | width: 40px !important; 184 | height: 40px !important; 185 | padding: 8px !important; 186 | } 187 | .dislike > #icon, .like > #icon { 188 | width: 24px !important; 189 | height: 24px !important; 190 | } 191 | } 192 | tp-yt-paper-icon-button.expand-button { 193 | visibility: hidden; 194 | display: none; 195 | } 196 | div#av-id { 197 | display: none !important; 198 | } 199 | div.background-image { 200 | position: fixed; 201 | width: 100vw; 202 | height: 100vh; 203 | opacity: 0.2; 204 | filter: blur(8px); 205 | } 206 | ytmusic-player-bar, 207 | div#player-bar-background { 208 | background: black !important; 209 | } 210 | `; 211 | styleTag.innerHTML = css; 212 | document.head.appendChild(styleTag); 213 | }; 214 | 215 | let showingExpandedControls = false 216 | const showExpandedControls = () => { 217 | const node = document.querySelector("ytmusic-app-layout"); 218 | if (node) { 219 | console.log("showing expanded controls"); 220 | showingExpandedControls = true; 221 | node.setAttribute("expanded-controls", ""); 222 | } 223 | }; 224 | 225 | const hideExpandedControls = () => { 226 | const node = document.querySelector("ytmusic-app-layout"); 227 | if (node) { 228 | console.log("hiding expanded controls"); 229 | showingExpandedControls = false; 230 | node.removeAttribute("expanded-controls"); 231 | } 232 | }; 233 | 234 | let clickedTab = null; 235 | const toggleSidePanel = (tab) => { 236 | const node = document.querySelector("ytmusic-app-layout"); 237 | if (node.hasAttribute("expanded-controls")) { 238 | hideExpandedControls(); 239 | } else if (tab === clickedTab) { 240 | showExpandedControls(); 241 | } 242 | clickedTab = tab; 243 | }; 244 | 245 | const onTabBarClicked = (e) => { 246 | toggleSidePanel(e.target); 247 | }; 248 | 249 | const setupPlayerPage = () => { 250 | const playerPage = document.querySelector("ytmusic-player-page"); 251 | if (playerPage) { 252 | let extraControls = playerPage.querySelector("div#extraControls"); 253 | if (!extraControls){ 254 | extraControls = document.createElement("div"); 255 | extraControls.setAttribute("id", "extraControls"); 256 | const mainPanel = playerPage.querySelector("div#main-panel"); 257 | mainPanel.parentNode.insertBefore(extraControls, mainPanel.nextSibling); 258 | 259 | const expandingMenu = document.querySelector("ytmusic-player-expanding-menu"); 260 | if (expandingMenu) { 261 | let node = expandingMenu.firstChild; 262 | while (node) { 263 | const nextSibling = node.nextSibling; 264 | expandingMenu.removeChild(node); 265 | extraControls.appendChild(node); 266 | node = nextSibling; 267 | } 268 | } 269 | const likeButtonRenderer = document.querySelector('ytmusic-like-button-renderer#like-button-renderer'); 270 | if (likeButtonRenderer) { 271 | likeButtonRenderer.parentNode.removeChild(likeButtonRenderer); 272 | extraControls.appendChild(likeButtonRenderer); 273 | } 274 | } 275 | 276 | const tabBar = document.querySelector('tp-yt-paper-tabs > #tabsContainer'); 277 | if (tabBar) { 278 | showExpandedControls(); 279 | console.log("creating event listener"); 280 | tabBar.addEventListener('click', onTabBarClicked); 281 | } 282 | 283 | const progressBar = playerPage.querySelector("tp-yt-paper-slider#progress-bar") 284 | if (progressBar) progressBar.setAttribute("focused", ""); 285 | } 286 | }; 287 | 288 | initStaticStyle(); 289 | 290 | if (window.uichanges === "loaded") return; 291 | window.uichanges = "loaded"; 292 | 293 | setupPlayerPage(); 294 | })(); 295 | -------------------------------------------------------------------------------- /www/js/plugins/xmlhttprequest.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | if (window.xhrrequest === "loaded") return; 3 | window.xhrrequest = "loaded"; 4 | 5 | console.log("loadding xmlhttprequest interceptor"); 6 | 7 | XMLHttpRequest.interceptors = []; 8 | XMLHttpRequest.addXHRInterceptor = function(fn) { 9 | if (XMLHttpRequest.interceptors.includes(fn)) return; 10 | XMLHttpRequest.interceptors.push(fn); 11 | } 12 | 13 | XMLHttpRequest.removeXHRInterceptor = function(fn) { 14 | var pos = XMLHttpRequest.interceptors.indexOf(fn); 15 | if (pos > -1) XMLHttpRequest.interceptors.splice(pos, 1); 16 | } 17 | 18 | function intercept(state, url, data) { 19 | for (var i = 0; i < XMLHttpRequest.interceptors.length; i++) { 20 | data = XMLHttpRequest.interceptors[i](state, url, data); 21 | } 22 | return data; 23 | } 24 | 25 | // based off https://stackoverflow.com/questions/16959359/intercept-xmlhttprequest-and-modify-responsetext 26 | var rawOpen = XMLHttpRequest.prototype.open; 27 | var rawSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader; 28 | var rawSend = XMLHttpRequest.prototype.send; 29 | 30 | XMLHttpRequest.prototype.open = function(method, url, _async, username, password) { 31 | if (!this._hooked) { 32 | this._hooked = true; 33 | setupHook(this); 34 | } 35 | if (intercept('open', url, true)) { 36 | rawOpen.apply(this, arguments); 37 | } 38 | } 39 | 40 | XMLHttpRequest.prototype.setRequestHeader = function(header, value) { 41 | try { 42 | rawSetRequestHeader.apply(this, arguments); 43 | } catch (ex) {} 44 | } 45 | 46 | XMLHttpRequest.prototype.send = function() { 47 | try { 48 | rawSend.apply(this, arguments); 49 | } catch (ex) {} 50 | } 51 | 52 | function setupHook(xhr) { 53 | function getter() { 54 | delete xhr.response; 55 | var ret = xhr.response; 56 | setup(); 57 | return intercept('response', xhr.responseURL, ret); 58 | } 59 | 60 | function setter(str) { 61 | } 62 | 63 | function getterText() { 64 | delete xhr.responseText; 65 | var ret = xhr.responseText; 66 | setup(); 67 | return intercept('response', xhr.responseURL, ret); 68 | } 69 | 70 | function setterText(str) { 71 | } 72 | 73 | function setup() { 74 | Object.defineProperty(xhr, 'responseText', { 75 | get: getterText, 76 | set: setterText, 77 | configurable: true 78 | }); 79 | Object.defineProperty(xhr, 'response', { 80 | get: getter, 81 | set: setter, 82 | configurable: true 83 | }); 84 | } 85 | setup(); 86 | } 87 | 88 | })(); 89 | --------------------------------------------------------------------------------