Last active
December 19, 2025 20:17
-
-
Save motebaya/22b6c85634360fb99f7e9a20b35a2d41 to your computer and use it in GitHub Desktop.
Automatic grabbing video url from bilibili profile with Tampermonkey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name biblibili url grabber | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2025-12-20 | |
| // @description easy pizy no need any extension | |
| // @author github.com/motebaya | |
| // @require file:///<YOUR_SHIT_PATH> | |
| // @match *://space.bilibili.com/*/upload/video* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=bilibili.com | |
| // @connect localhost | |
| // ==/UserScript== | |
| (function () { | |
| "use strict"; | |
| let pn = document.createElement("div"); | |
| pn.style.cssText = ` | |
| position: fixed; | |
| top: 350px; | |
| left: 150px; | |
| width: 250px; | |
| height: 250px; | |
| background: #111; | |
| color: #eee; | |
| z-index: 999999; | |
| border-radius: 10px; | |
| box-shadow: 0 10px 30px rgba(0,0,0,.4); | |
| font-family: monospace; | |
| display: flex; | |
| flex-direction: column; | |
| `; | |
| // HEADER | |
| let h = document.createElement("div"); | |
| h.textContent = "Bilibili Grabber"; | |
| h.style.cssText = ` | |
| padding: 8px; | |
| cursor: move; | |
| background: #1c1c1c; | |
| text-align: center; | |
| user-select: none; | |
| border-radius: 10px 10px 0 0; | |
| `; | |
| // BUTTON | |
| let btn = document.createElement("button"); | |
| btn.textContent = "Start"; | |
| btn.style.cssText = ` | |
| margin: 8px; | |
| padding: 6px; | |
| background: #2e7dff; | |
| border: none; | |
| color: white; | |
| border-radius: 6px; | |
| cursor: pointer; | |
| `; | |
| // TEXTAREA/LOG | |
| let log = document.createElement("textarea"); | |
| log.readOnly = true; | |
| log.style.cssText = ` | |
| flex: 1; | |
| margin: 8px; | |
| resize: none; | |
| background: #000; | |
| color: #0f0; | |
| border: 1px solid #333; | |
| border-radius: 6px; | |
| padding: 6px; | |
| font-size: 12px; | |
| `; | |
| function sendLog(msg) { | |
| log.value += msg + "\n"; | |
| log.scrollTop = log.scrollHeight; | |
| } | |
| let isDragging = false; | |
| let offsetX = 0; | |
| let offsetY = 0; | |
| h.addEventListener("mousedown", (e) => { | |
| isDragging = true; | |
| offsetX = e.clientX - pn.offsetLeft; | |
| offsetY = e.clientY - pn.offsetTop; | |
| }); | |
| document.addEventListener("mousemove", (e) => { | |
| if (!isDragging) return; | |
| pn.style.left = e.clientX - offsetX + "px"; | |
| pn.style.top = e.clientY - offsetY + "px"; | |
| }); | |
| document.addEventListener("mouseup", () => { | |
| isDragging = false; | |
| }); | |
| pn.appendChild(h); | |
| pn.appendChild(btn); | |
| pn.appendChild(log); | |
| document.body.appendChild(pn); | |
| /** | |
| * CORE & ACTION | |
| */ | |
| btn.addEventListener("click", async () => { | |
| sendLog("Starting..."); | |
| const nickname = document.querySelector("div.nickname")?.textContent ?? "-"; | |
| const userId = window.location.href.match(/\.com\/(\d+)/)[1]; | |
| sendLog(`User: ${nickname} (${userId})`); | |
| /** | |
| * GRAB VIDEO URLS | |
| */ | |
| let PAGE = 1; | |
| let videoList = []; | |
| while (1) { | |
| let videoUrl = Array.from( | |
| document.querySelectorAll(".video-list > .upload-video-card") | |
| ).map((i) => { | |
| return i | |
| .querySelector("div > a ") | |
| .getAttribute("href") | |
| .split("?")[0] | |
| .split("/") | |
| .slice(-2)[0]; | |
| }); | |
| sendLog(`Grabbed: ${videoList.length} Video Url`); | |
| if (videoUrl.length >= 1) { | |
| sendLog(`Grabbing ${videoUrl.length} from page: ${PAGE}`); | |
| videoList.push(...videoUrl); | |
| PAGE += 1; | |
| // next PAGE | |
| let pageBtn = Array.from( | |
| document.querySelectorAll( | |
| 'button[class*="vui_pagenation"]:not(.vui_button--active)' | |
| ) | |
| ).find((i) => i.textContent.trim() === String(PAGE)); | |
| if (pageBtn) { | |
| pageBtn.click(); | |
| await new Promise((resolve) => setTimeout(resolve, 1000)); | |
| } else { | |
| sendLog(` -- No more page after: ${PAGE}`); | |
| break; | |
| } | |
| } else { | |
| sendLog(" -- No video found"); | |
| break; | |
| } | |
| } | |
| /** | |
| * CREATE BLOB | |
| */ | |
| sendLog(` -- Creating BLOB`); | |
| let blob = new Blob([videoList.join("\n")], { type: "text/plain" }); | |
| let url = URL.createObjectURL(blob); | |
| let a = document.createElement("a"); | |
| a.href = url; | |
| a.download = `${nickname.trim()}_${userId}.txt`; | |
| a.click(); | |
| sendLog(` -- BLOB: ${url}`); | |
| }); | |
| })(); |
Author
motebaya
commented
Dec 19, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment