From 2f3da283fb314e3817b87ad1d8ab14dabd5c3470 Mon Sep 17 00:00:00 2001 From: Sushi Date: Sun, 20 Mar 2022 12:42:12 -0600 Subject: [PATCH] better description, ryd plugin --- NUXT/nuxt.config.js | 3 +- NUXT/pages/watch.vue | 44 ++++++++++++++---- NUXT/plugins/ryd.js | 103 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 10 deletions(-) create mode 100644 NUXT/plugins/ryd.js diff --git a/NUXT/nuxt.config.js b/NUXT/nuxt.config.js index 1a3819c..7e91fc4 100644 --- a/NUXT/nuxt.config.js +++ b/NUXT/nuxt.config.js @@ -16,7 +16,8 @@ export default { target: 'static', plugins: [ { src: "~/plugins/youtube", mode: "client" }, - { src: "~/plugins/vuetube", mode: "client" } + { src: "~/plugins/vuetube", mode: "client" }, + { src: "~/plugins/ryd", mode: "client"} ], generate: { dir: '../dist' diff --git a/NUXT/pages/watch.vue b/NUXT/pages/watch.vue index 20b8059..0dcbfad 100644 --- a/NUXT/pages/watch.vue +++ b/NUXT/pages/watch.vue @@ -4,13 +4,13 @@ {{ title }} - {{ views }} views • {{uploaded}}
+ {{ views }} views • {{uploaded}}

- +
@@ -18,15 +18,22 @@ + - mdi-chevron-up + + mdi-chevron-up + mdi-chevron-down + +
+
+ {{ description }} +
- - + + + + + +
+ {{ description }} +
+
@@ -56,16 +73,23 @@ import recommended from '../components/recommended.vue'; export default { components: { recommended }, + methods: { + dislike() { + }, + share() { + this.share = !this.share; + } + }, data() { return { interactions: [ { name: "Likes", icon: "mdi-thumb-up", action: null, value: this.likes, disabled: true }, - { name: "Dislikes", icon: "mdi-thumb-down", action: null, value: this.dislikes, disabled: true }, - { name: "Share", icon: "mdi-share", action: null, disabled: true }, + { name: "Dislikes", icon: "mdi-thumb-down", action: this.dislike(), value: this.dislikes, disabled: true }, + { name: "Share", icon: "mdi-share", action: this.share(), disabled: true }, ], showMore: false, - + share: false, title: null, uploaded: null, vidSrc: null, @@ -91,7 +115,9 @@ export default { this.interactions[0].value = data.likes.toString(); }); - this.$youtube.getReturnYoutubeDislike(this.$route.query.v, (data) => { + this.$ryd.getDislikes(this.$route.query.v, (data) => { + console.log('real data') + console.log(data) this.interactions[1].value = data.dislikes.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }); diff --git a/NUXT/plugins/ryd.js b/NUXT/plugins/ryd.js new file mode 100644 index 0000000..069bb4d --- /dev/null +++ b/NUXT/plugins/ryd.js @@ -0,0 +1,103 @@ +//--- Modules/Imports ---// +import { Http } from '@capacitor-community/http'; +import constants from '../static/constants'; + +function generateUserID(length = 36) { + const charset = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + let result = ""; + if (crypto && crypto.getRandomValues) { + const values = new Uint32Array(length); + crypto.getRandomValues(values); + for (let i = 0; i < length; i++) { + result += charset[values[i] % charset.length]; + } + return result; + } else { + for (let i = 0; i < length; i++) { + result += charset[Math.floor(Math.random() * charset.length)]; + } + return result; + } + } + +function countLeadingZeroes(uInt8View, limit) { + let zeroes = 0; + let value = 0; + for (let i = 0; i < uInt8View.length; i++) { + value = uInt8View[i]; + if (value === 0) { + zeroes += 8; + } else { + let count = 1; + if (value >>> 4 === 0) { + count += 4; + value <<= 4; + } + if (value >>> 6 === 0) { + count += 2; + value <<= 2; + } + zeroes += count - (value >>> 7); + break; + } + if (zeroes >= limit) { + break; + } + } + return zeroes; + } + +//--- Puzzle Solver from Anarios --// +async function solvePuzzle(puzzle) { + let challenge = Uint8Array.from(atob(puzzle.challenge), (c) => + c.charCodeAt(0) + ); + let buffer = new ArrayBuffer(20); + let uInt8View = new Uint8Array(buffer); + let uInt32View = new Uint32Array(buffer); + let maxCount = Math.pow(2, puzzle.difficulty) * 5; + for (let i = 4; i < 20; i++) { + uInt8View[i] = challenge[i - 4]; + } + + for (let i = 0; i < maxCount; i++) { + uInt32View[0] = i; + let hash = await crypto.subtle.digest("SHA-512", buffer); + let hashUint8 = new Uint8Array(hash); + if (countLeadingZeroes(hashUint8) >= puzzle.difficulty) { + return { + solution: btoa(String.fromCharCode.apply(null, uInt8View.slice(0, 4))), + }; + } + } + } + + + +const rydModule = { + logs: new Array(), + + //--- Get Dislikes ---// + getDislikes(id, callback) { + console.log("fetching ryd") + Http.request({ + method: 'GET', + url: `https://returnyoutubedislikeapi.com/votes`, + params: { videoId: id } + }) + .then((res) => { + callback(res.data) + }) + .catch((err) => { + callback(err); + }); + } + +} + +//--- Start ---// +export default ({ app }, inject) => { + inject('ryd', {...rydModule}) +} +