Skip to content

Instantly share code, notes, and snippets.

@sambatlim
Created January 12, 2023 11:05
Show Gist options
  • Save sambatlim/ce89b4bd81361cc2caf55a454d335fa8 to your computer and use it in GitHub Desktop.
Save sambatlim/ce89b4bd81361cc2caf55a454d335fa8 to your computer and use it in GitHub Desktop.
kuaishou downloader
// ==UserScript==
// @name kuaishou_easy_download
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author Sambat
// @match https://www.kuaishou.com/short-video/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant GM_download
// ==/UserScript==
(function () {
'use strict';
const MobileUA ="Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1";
function addDownloadButton() {
const buttonEl = document.createElement("button");
buttonEl.textContent = "Download";
document.body.appendChild(buttonEl);
buttonEl.style.position = 'fixed'
buttonEl.style.zIndex = '10000'
buttonEl.style.top = '0'
buttonEl.style.left = '0'
buttonEl.style.width = '25%'
buttonEl.style.height = '60px'
let videourl = document.querySelector("video.player-video").src;
let fileName = `${document.querySelector("p.video-info-title").innerText}.mp4`
buttonEl.addEventListener("click", () => {
GM_download({
url: videourl,
headers: {
"user-agent": MobileUA,
},
name: fileName,
});
});
}
addDownloadButton();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment