title | date | categories | |
---|---|---|---|
Download_watchingVideo.Js |
2023-11-23 |
|
how to add bookmarklet in chrome
import { runScriptInCurrentTab, showLoading } from "./helpers/utils.js"; export default { icon: "", name: { en: "Download watching video", vi: "Download watching video", }, description: { en: "tiktok, doutu.be, phimmoi2...", vi: "tiktok, doutu.be, phimmoi2...", }, onClickExtension: async() => { let src = await runScriptInCurrentTab(async() => { return await UsefulScriptGlobalPageContext.DOM.getWatchingVideoSrc(); }); if (!src) { alert("Video not found"); return; } const { closeLoading, setLoadingText } = showLoading("Video loading..."); await UsefulScriptGlobalPageContext.Utils.downloadBlobUrl( src, "video.mp4", (loaded, total) => { let loadedMB = ~~(loaded / 1024 / 1024); let totalMB = ~~(total / 1024 / 1024); let percent = ((loaded/total) * 100) | 0; setLoadingText( 'Loading video... (${loadedMB}/${totalMB}MB – ${percent}%)' ); } ); closeLoading(); }, };