diff --git a/README.md b/README.md index 5a387741..e76836d2 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Youtube App without ADs ## Pre-requisites * Install webOS SDK - https://webostv.developer.lge.com/sdk/installation/ * Setup webOS app testing to load apps in developer mode - https://webostv.developer.lge.com/develop/app-test +* Uninstall YouTube app. ## Building * Clone the repository @@ -23,5 +24,5 @@ ares-install -d <.ipk file> ## Launching * The app will be available in the TV's app list or launch it using ares-cli. ``` -ares-launch -d com.youtube.noads +ares-launch -d youtube.leanback.v4 ``` \ No newline at end of file diff --git a/appinfo.json b/appinfo.json index b8d3b9de..cd5e538d 100644 --- a/appinfo.json +++ b/appinfo.json @@ -1,10 +1,19 @@ { - "id": "com.youtube.noads", + "id": "youtube.leanback.v4", "version": "0.0.1", "vendor": "My Company", "type": "web", "main": "index.html", "title": "Youtube Without ADs", "icon": "icon.png", - "largeIcon": "largeIcon.png" + "largeIcon": "largeIcon.png", + "support360Content": true, + "accessibility": { + "supportsAudioGuidance": true + }, + "privilegedJail": true, + "supportQuickStart": true, + "dialAppName": "YouTube", + "disableBackHistoryAPI": true, + "noSplashOnLaunch": true } \ No newline at end of file diff --git a/index.html b/index.html index 90edf9e5..7ddec44e 100755 --- a/index.html +++ b/index.html @@ -2,32 +2,6 @@ - - - + - \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 00000000..bfd30b17 --- /dev/null +++ b/index.js @@ -0,0 +1,28 @@ +const CONTENT_TARGET_LAUNCH_PARAMETER = "contentTarget"; +const YOUTUBE_TV_URL = "https://www.youtube.com/tv"; + +function extractLaunchUrlParams(launchParameters) { + if (launchParameters === null || launchParameters === "") { + return null; + } + const launchParamJson = JSON.parse(launchParameters); + return launchParamJson[CONTENT_TARGET_LAUNCH_PARAMETER]; +} + +function concatenateUrlAndGetParams(ytUrl, path) { + if (path === null) { + return ytUrl; + } else { + return ytUrl + "?" + path; + } +} + +function main() { + const launchParameters = window.PalmSystem.launchParams; + const youtubeLaunchUrlPath = extractLaunchUrlParams(launchParameters); + + window.location = concatenateUrlAndGetParams(YOUTUBE_TV_URL, youtubeLaunchUrlPath); +} + + +main(); \ No newline at end of file diff --git a/webOSUserScripts/userScript.js b/webOSUserScripts/userScript.js index e9541a96..14fabdf9 100644 --- a/webOSUserScripts/userScript.js +++ b/webOSUserScripts/userScript.js @@ -10,8 +10,8 @@ const settings = { disable_annotations: false, }; -const isRequestBlocked = (requestType, url) => { - +function isRequestBlocked(requestType, url) { + console.log(`[${requestType}] URL : ${url}`); if (settings.disable_ads && YOUTUBE_AD_REGEX.test(url)) { @@ -49,7 +49,7 @@ XMLHttpRequest.prototype.open = function (...args) { * Wrapper over Fetch. */ const origFetch = fetch; -fetch = (...args) => { +fetch = function (...args) { const requestType = "FETCH"; const url = args[0];