-
-
Save markx/56121560a211be81bf3355527332bff5 to your computer and use it in GitHub Desktop.
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 WeiyunExporter | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.weiyun.com/disk* | |
// @grant none | |
// ==/UserScript== | |
'use strict'; | |
function escapeQuote(str) { | |
return str.replace("\"", "\\\""); | |
} | |
function buildAria2Url(name, url) { | |
return `aria2c -c -k1M -s100 ` + | |
`-o "${escapeQuote(name)}" ` + | |
`--header "${escapeQuote(window.navigator.userAgent)}" ` + | |
`--header "Referer: ${escapeQuote(window.location.toString())}" ` + | |
`--header "Cookie: ${escapeQuote(window.document.cookie)}" ` + | |
`"${escapeQuote(url)}"`; | |
} | |
function buildMpvUrl(name, url) { | |
return `mpv ` + | |
`--user-agent="${escapeQuote(window.navigator.userAgent)}" ` + | |
`--http-header-fields="Referer: ${escapeQuote(window.location.toString())}","Cookie: ${escapeQuote(window.document.cookie)}" ` + | |
`"${escapeQuote(url)}"`; | |
} | |
window.daochu = function(handle) { | |
const id = Math.random().toString(36).substring(7); | |
webpackJsonp([2], { | |
[id]: function(m, e, r) { | |
const lookupWYFunction = function(name) { | |
return Object.values(r.c).map((x) => x.exports).filter((x) => x[name] !== undefined); | |
}; | |
const list = document.querySelectorAll(".list-group-bd")[2].__vue__.selectedList; | |
const getSingleUrl = lookupWYFunction("getSingleUrl")[0].getSingleUrl; | |
list.map(node => { | |
getSingleUrl(node).then(data => { | |
const r = handle(node.getName(), data.https_download_url); | |
console.log(r); | |
alert(r); | |
}, error => { | |
console.warn(error); | |
}); | |
}); | |
} | |
}, [id]); | |
} | |
let addMenu = () => { | |
let menu = `<div class="action-item" id="export-button"><div class="action-item-con"><i class="icon icon-download"></i><span class="act-txt">Export</span></div></div> \ | |
<div class="action-item" id="mpv-button"><div class="action-item-con"><i class="icon icon-video"></i><span class="act-txt">MPV</span></div></div>` | |
document.querySelector('div.mod-action-wrap-menu:nth-child(1) > div:nth-child(2)').insertAdjacentHTML('afterend', menu) | |
let btn = document.querySelector('#export-button') | |
btn.addEventListener('click', (event) => { | |
window.daochu(buildAria2Url); | |
event.preventDefault(); | |
}) | |
let btn2 = document.querySelector('#mpv-button') | |
btn2.addEventListener('click', (event) => { | |
window.daochu(buildMpvUrl); | |
event.preventDefault(); | |
}) | |
} | |
setTimeout(addMenu, 3000); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment