tianyunperfect 2 年之前
父节点
当前提交
a64ee078c7
共有 3 个文件被更改,包括 163 次插入1 次删除
  1. 44 0
      tmp/monkey/B站-复制视频引用.js
  2. 56 0
      tmp/monkey/excalidraw.js
  3. 63 1
      tmp/tmp.js

+ 44 - 0
tmp/monkey/B站-复制视频引用.js

@@ -0,0 +1,44 @@
+// ==UserScript==
+// @name        T-B站-复制视频引用
+// @namespace   Violentmonkey Scripts
+// @match       https://www.bilibili.com/video/*
+// @grant       none
+// @version     1.0
+// @author      tianyunperfect
+// @require     https://cdn.bootcdn.net/ajax/libs/jquery/3.3.1/jquery.min.js
+// @description 2021/1/30 下午7:09:51
+// ==/UserScript==
+(function () {
+    'use strict';
+    jQuery.noConflict();
+
+    function getTempId() {
+        return "myTmp" + Math.floor(Math.random() * 10000);
+    }
+
+    function myCopy(string) {
+        let tmpId = getTempId();
+        jQuery('body').append(jQuery("<div id='"+tmpId+"'>"+string+"</div>"))
+        let range = document.createRange();
+        range.selectNode(jQuery("#" + tmpId)[0]);
+        // 清除选择
+        window.getSelection().removeAllRanges();
+        window.getSelection().addRange(range);
+        console.log('复制成功');
+        document.execCommand('copy');
+        // 清除选择
+        window.getSelection().removeAllRanges();
+        jQuery('#' + tmpId).remove();
+    }
+
+    jQuery('.tit').dblclick(function () {
+        // let url = `https://player.bilibili.com/player.html?high_quality=1&danmaku=0&bvid=${bvid}`;
+        let url = `https://video-direct-link.vercel.app/bili.mp4?aid=${aid}&bvid=${bvid}&cid=${cid}`;
+        myCopy(url);
+        let tmpId = getTempId();
+        jQuery(".tit").eq(0).append(jQuery('<span class="tag" id="' + tmpId + '">:已复制</span>'));
+        setTimeout(() => {
+            jQuery('#' + tmpId).remove();
+        }, 1500)
+    });
+})();

+ 56 - 0
tmp/monkey/excalidraw.js

@@ -0,0 +1,56 @@
+// ==UserScript==
+// @name              T-excalidraw-远程同步
+// @author            tianyunperfect
+// @description       简介
+// @version           1.0.0
+// @update            2021-07-08 16:16:14
+// @include           https://excalidraw.tianyunperfect.cn/?a=*
+// @require           https://git.tianyunperfect.cn/tianyunperfect/web-base/raw/master/tmp/monkey/util.js?a=2022年06月26日21:06:37
+// @require           https://cdn.bootcdn.net/ajax/libs/js-cookie/3.0.1/js.cookie.min.js
+// @require           https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js
+
+
+// ==/UserScript==
+(async () => {
+    if (window.top !== window.self) {
+        return;
+    }
+
+    let key = "excalidraw";
+
+    let id = getQueryString("a");
+    axios.post(`https://web_history.tianyunperfect.cn/excalidraw/get`, {
+        "id": id,
+        "json_str": "[]"
+    }).then(async res => {
+        // 远程数据
+        let data = res.data;
+        if (data.message) {
+            if (data.message != localStorage.getItem(key)) {
+                localStorage.setItem(key, data.message);
+                location.reload();
+            }
+        } else {
+            await axios.post(`https://web_history.tianyunperfect.cn/excalidraw/insert`, {
+                "id": id,
+                "json_str": "[]"
+            })
+            localStorage.setItem(key, "[]");
+            location.reload();
+        }
+        let json_str = localStorage.getItem(key);
+        // 同步数据
+        while (true) {
+            await sleep(1000);
+            let json_new = localStorage.getItem(key);
+            if (json_str != json_new) {
+                json_str = json_new;
+                await axios.post(`https://web_history.tianyunperfect.cn/excalidraw/update`, {
+                    "id": id,
+                    "json_str": json_new
+                });
+            }
+        }
+
+    })
+})();

+ 63 - 1
tmp/tmp.js

@@ -1 +1,63 @@
-console.log(" 123  123".replaceAll(" ", "&nbsp;"));
+const table = [...'fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF'];
+const s = [11, 10, 3, 8, 4, 6];
+const xor = 177451812;
+const add = 8728348608;
+
+const av2bv = (av) => {
+    let num = NaN;
+    if (Object.prototype.toString.call(av) === '[object Number]') {
+        num = av;
+    } else if (Object.prototype.toString.call(av) === '[object String]') {
+        num = parseInt(av.replace(/[^0-9]/gu, ''));
+    }
+    ;
+    if (isNaN(num) || num <= 0) {
+        // 网页版直接输出这个结果了
+        return '¿你在想桃子?';
+    }
+    ;
+
+    num = (num ^ xor) + add;
+    let result = [...'bv1  4 1 7  '];
+    let i = 0;
+    while (i < 6) {
+        // 这里改写差点犯了运算符优先级的坑
+        // 果然 Python 也不是特别熟练
+        // 说起来 ** 按照传统语法应该写成 Math.pow(),但是我个人更喜欢 ** 一些
+        result[s[i]] = table[Math.floor(num / 58 ** i) % 58];
+        i += 1;
+    }
+    ;
+    return result.join('');
+};
+
+const bv2av = (bv) => {
+    let str = '';
+    if (bv.length === 12) {
+        str = bv;
+    } else if (bv.length === 10) {
+        str = `BV${bv}`;
+        // 根据官方 API,BV 号开头的 BV1 其实可以省略
+        // 不过单独省略个 B 又不行(
+    } else if (bv.length === 9) {
+        str = `BV1${bv}`;
+    } else {
+        return '¿你在想桃子?';
+    }
+    ;
+    if (!str.match(/[Bb][Vv][fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF]{10}/gu)) {
+        return '¿你在想桃子?';
+    }
+    ;
+
+    let result = 0;
+    let i = 0;
+    while (i < 6) {
+        result += table.indexOf(str[s[i]]) * 58 ** i;
+        i += 1;
+    }
+    ;
+    return `av${result - add ^ xor}`;
+};
+console.log(bv2av("BV16Y4y1w7Sb"));
+// https://video-direct-link.vercel.app/bili.mp4?aid=av644205043&bvid=BV16Y4y1w7Sb