From 5ab2c69698eb91a3afcecc79116cdda39bb4e8c6 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Fri, 30 Jul 2021 22:00:43 +0200 Subject: add incomplete odysee fix --- phttps___odysee.com.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 phttps___odysee.com.json diff --git a/phttps___odysee.com.json b/phttps___odysee.com.json new file mode 100644 index 0000000..e6a66e5 --- /dev/null +++ b/phttps___odysee.com.json @@ -0,0 +1 @@ +[{"sodysee":{"url":"","hash":"","text":"/**\n * Copyright 2021 Wojtek Kosior\n *\n * This program is free software; you can redistribute it\n * and/or modify it under the terms of either:\n * - the GNU General Public License as published by the Free\n * Software Foundation; either version 3 of the License, or (at\n * your option) any later version, or\n * - the \"A\" license: ; explained\n * at: \n *\n * As additional permission under GNU GPL version 3 section 7, you\n * may distribute forms of that code without the copy of the GNU\n * GPL normally required by section 4, provided you include this\n * license notice and, in case of non-source distribution, a URL\n * through which recipients can access the Corresponding Source.\n * If you modify file(s) with this exception, you may extend this\n * exception to your version of the file(s), but you are not\n * obligated to do so. If you do not wish to do so, delete this\n * exception statement from your version. If you delete this\n * exception statement from all source files in the program, then\n * also delete it here.\n *\n * As a special exception to the GPL, any HTML file which merely\n * makes function calls to this code, and for that purpose\n * includes it by reference shall be deemed a separate work for\n * copyright law purposes. If you modify this code, you may extend\n * this exception to your version of the code, but you are not\n * obligated to do so. If you do not wish to do so, delete this\n * exception statement from your version.\n */\n\n/* use with https://odysee.com/*** */\n\n/* If we're on a video page, show the video. */\n\nlet data = null;\n\nfunction process_json_script(json_script)\n{\n try {\n\tdata = JSON.parse(json_script.textContent);\n } catch (e) {\n\tconsole.log(\"Error parsing content data\", e);\n }\n}\n\nfor (const json_script of document.querySelectorAll(\"head script\")) {\n if (json_script.getAttribute(\"blocked-type\") === \"application/ld+json\")\n\tprocess_json_script(json_script);\n}\n\nconst body = document.createElement(\"body\");\n\nif (data) {\n if (data[\"@type\"] === \"VideoObject\" && data.contentUrl) {\n\tconst video = document.createElement(\"video\");\n\tconst source = document.createElement(\"source\");\n\n\tsource.src = data.contentUrl;\n\n\tvideo.setAttribute(\"width\", \"100%\");\n\tvideo.setAttribute(\"height\", \"auto\");\n\tvideo.setAttribute(\"controls\", \"\");\n\n\tvideo.appendChild(source);\n\n\tbody.appendChild(video);\n }\n\n if (data.name) {\n\tconst h1 = document.createElement(\"h1\");\n\n\th1.textContent = data.name;\n\th1.setAttribute(\"style\", \"color: #555;\");\n\n\tbody.appendChild(h1);\n }\n\n if (data.uploadDate) {\n\ttry {\n\t const date = new Date(data.uploadDate).toString();\n\t const date_div = document.createElement(\"div\");\n\n\t date_div.textContent = `Uploaded: ${date}`;\n\t date_div.setAttribute(\"style\", \"font-size: 8; font-weight: bold;\");\n\n\t body.appendChild(date_div);\n\t} catch(e) {\n\t console.log(\"Error parsing content upload date\", e);\n\t}\n }\n\n if (data.description) {\n\tconst description_div = document.createElement(\"div\");\n\n\tdescription_div.textContent = data.description;\n\n\tbody.appendChild(description_div);\n }\n}\n\n/* Show search. */\n\nconst search_input = document.createElement(\"input\");\nconst search_submit = document.createElement(\"button\");\nconst search_form = document.createElement(\"form\");\nconst error_div = document.createElement(\"div\");\n\nsearch_submit.textContent = \"Search Odysee\";\n\nsearch_form.setAttribute(\"style\", \"margin: 15px 0 0 0;\");\n\nsearch_form.appendChild(search_input);\nsearch_form.appendChild(search_submit);\n\nerror_div.textContent = \"Failed to perform search :c\";\nerror_div.setAttribute(\"style\", \"display: none;\");\n\nbody.appendChild(search_form);\nbody.appendChild(error_div);\n\n/* Replace the UI. */\n\ndocument.documentElement.replaceChild(body, document.body);\n\n/* Add the logic of performing search and showing results. */\n\nlet results_div = null;\n\nfunction ajax_callback(xhttp, cb)\n{\n if (xhttp.readyState === 4)\n\tcb(xhttp.response);\n}\n\nfunction show_search_entries(new_results_div, response)\n{\n try {\n\tvar response_data = JSON.parse(response);\n } catch (e) {\n\terror_div.setAttribute(\"style\", \"color: #b44;\");\n\tconsole.log(\"Failed to parse search response :c\", e);\n\treturn;\n }\n\n if (results_div)\n\tresults_div.remove();\n\n error_div.setAttribute(\"style\", \"display: none;\");\n\n results_div = new_results_div;\n new_results_div.textContent = response;\n\n body.appendChild(results_div);\n}\n\nfunction get_search_entries(new_results_div, query)\n{\n const callback = r => show_search_entries(new_results_div, r);\n const url = `https://lighthouse.odysee.com/search?s=${encodeURIComponent(query)}&size=20&from=0&claimType=file,channel&nsfw=false&free_only=true`;\n\n xhttp = new XMLHttpRequest();\n xhttp.onreadystatechange = () => ajax_callback(xhttp, callback);\n xhttp.open(\"GET\", url, true);\n try {\n\txhttp.send();\n } catch(e) {\n\tconsole.log(\"Failed to query search server :c\", e);\n\terror_div.setAttribute(\"style\", \"color: #b44;\");\n }\n}\n\nfunction search(event)\n{\n if (event)\n\tevent.preventDefault();\n console.log(\"search\", search_input.value);\n if (!/[^\\s]/.test(search_input.value))\n\treturn;\n\n const new_results_div = document.createElement(\"div\");\n\n get_search_entries(new_results_div, search_input.value);\n}\n\nsearch_form.addEventListener(\"submit\", search);\n\n\nconst match = /^[^?]*search\\?q=([^&]+)/.exec(document.URL)\nif (match) {\n search_input.value = decodeURIComponent(match[1]);\n search();\n}\n"}},{"phttps://odysee.com":{"components":["s","odysee"],"allow":false}},{"phttps://odysee.com/***":{"components":["s","odysee"],"allow":false}}] -- cgit v1.2.3