From e24c60dd6acbb8db5912a7715c302374d7eb18b8 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Fri, 18 Feb 2022 18:51:22 +0100 Subject: translate all site fixes to the new Hydrilla format Fixes in new format are yet to be tested. Things may break. Alternative site interfaces were removed. This repository is meant exclusively for holding fixes for js-encumbered websites. Jahoti's SParse code shall be put in a separate repository. --- content/syewtube_urls/index.json | 6 ---- content/syewtube_urls/yewtube_urls.js | 57 ----------------------------------- 2 files changed, 63 deletions(-) delete mode 100644 content/syewtube_urls/index.json delete mode 100644 content/syewtube_urls/yewtube_urls.js (limited to 'content/syewtube_urls') diff --git a/content/syewtube_urls/index.json b/content/syewtube_urls/index.json deleted file mode 100644 index df8330d..0000000 --- a/content/syewtube_urls/index.json +++ /dev/null @@ -1,6 +0,0 @@ -{ -"type" : "script", -"name" : "youtube.com_2_yewtu.be_URL_converter", -"sha256" : "ae2abac001a7256f4b4a66846264470b2898aa736a55f91022017ce7634dd1ae", -"location" : "yewtube_urls.js" -} diff --git a/content/syewtube_urls/yewtube_urls.js b/content/syewtube_urls/yewtube_urls.js deleted file mode 100644 index b013132..0000000 --- a/content/syewtube_urls/yewtube_urls.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (C) 2021, Wojtek Kosior - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the CC0 1.0 Universal License as published by - * the Creative Commons Corporation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * CC0 1.0 Universal License for more details. - * Available under the terms of Creative Commons Zero. - */ - -/* Library to convert youtube.com URLs to yewtu.be URLs. */ - -function decode_query_options(url) -{ - const query_options = {}; - const match = /^[^?]*\?(.*)/.exec(url); - if (!match) - return query_options; - - for (const opt of match[1].split("&")) { - const [key, val] = - /^([^=]*)=?(.*)/.exec(opt).splice(1, 2).map(decodeURIComponent); - query_options[key] = val; - } - - return query_options; -} - -function encode_query_options(query_options) -{ - return Object.entries(query_options) - .map(ar => ar.map(encodeURIComponent).join("=")).join("&"); -} - -function make_yewtube_url(youtube_url) -{ - const query_options = decode_query_options(youtube_url); - - let endpoint = ""; - - const match = /^(?:(?:https?:)?\/\/)?[^/]*\/([^?]*)/.exec(youtube_url); - if (match) - endpoint = match[1]; - - if (/^embed\//.test(query_options.v)) - endpoint = query_options.v; - - if (/^embed\/.+/.test(endpoint)) - delete query_options.v - - const encoded_options = encode_query_options(query_options); - return `https://yewtu.be/${endpoint}?${encoded_options}`; -} -- cgit v1.2.3