// ==UserScript==
// @name 音视频捕获器
// @version 0.6
// @description 原 影音捕获器。捕获音乐、视频网站上的音乐、视频的下载链接。单击页面最右边的《 来打开捕获列表,双击捕获列表来关闭它。
// @author Sam0230
// @match *://*/*
// @grant none
// @run-at document-start
// @namespace https://gf.qytechs.cn/users/207000
// ==/UserScript==
(function () {
'use strict';
function process(outerHTML) {
var i, result = "";
while (outerHTML.indexOf("src=\"") != -1) {
i = outerHTML.indexOf("src=\"") + 5;
while (outerHTML[i] != '"' && i < outerHTML.length) {
result += outerHTML[i];
++ i;
}
if (i < outerHTML.length) {
result += "\r\n";
}
outerHTML = outerHTML.replace("src=\"", "");
}
return result;
}
(function () {
var playOriginal = HTMLAudioElement.prototype.play;
function play() {
if (this.src) {
window.top.postMessage(Array("audioVideoCapturer", this.src), '*');
} else {
window.top.postMessage(Array("audioVideoCapturer", process(this.outerHTML)), '*');
}
HTMLAudioElement.prototype.play = playOriginal;
var result = this.play();
HTMLAudioElement.prototype.play = play;
return result;
}
HTMLAudioElement.prototype.play = play;
HTMLAudioElement.prototype.play.toString = function () {
return "function play() { [native code] }";
};
})();
(function () {
var playOriginal = HTMLVideoElement.prototype.play;
function play() {
if (this.src) {
window.top.postMessage(Array("audioVideoCapturer", this.src), '*');
} else {
window.top.postMessage(Array("audioVideoCapturer", process(this.outerHTML)), '*');
}
HTMLVideoElement.prototype.play = playOriginal;
var result = this.play();
HTMLVideoElement.prototype.play = play;
return result;
}
HTMLVideoElement.prototype.play = play;
HTMLVideoElement.prototype.play.toString = function () {
return "function play() { [native code] }";
};
})();
var iframe2;
function main() {
if (document.body) {
function hide_1() {
iframe.style.backgroundColor = "rgba(0, 0, 0, 0.1)";
iframe.contentDocument.body.style.color = "rgba(255, 255, 255, 0.4)";
}
function show_1() {
iframe.style.backgroundColor = "rgba(0, 0, 0, 0.5)";
iframe.contentDocument.body.style.color = "rgba(255, 255, 255, 0.8)";
}
function show_2_hide_1() {
iframe2.style.transform = "translate(-300px, 0)";
iframe.contentDocument.body.onmousemove = undefined;
iframe.contentDocument.body.onmouseout = undefined;
iframe.contentDocument.body.onmouseover = undefined;
setTimeout(function() {
iframe.style.backgroundColor = "rgba(0, 0, 0, 0)";
iframe.contentDocument.body.style.color = "rgba(255, 255, 255, 0)";
}, 50);
}
function show_1_hide_2() {
iframe2.style.transform = "none";
iframe.contentDocument.body.onmousemove = show_1;
iframe.contentDocument.body.onmouseover = show_1;
iframe.contentDocument.body.onmouseout = hide_1;
hide_1();
}
var iframe = document.createElement("iframe");
iframe.style.border = "none";
iframe.style.zIndex = 10000;
iframe.style.height = "31px";
iframe.style.width = "23px";
iframe.style.position = "fixed";
iframe.style.right = "0";
iframe.style.top = "50%";
iframe.style.margin = "-15px 0 0 0";
iframe.style.backgroundColor = "rgba(0, 0, 0, 0.1)";
iframe.style.transition = "all 0.3s linear";
document.body.appendChild(iframe);
iframe.contentDocument.body.style.cursor = "pointer";
iframe.contentDocument.body.style.margin = 0;
iframe.contentDocument.body.style.lineHeight = "150%";
iframe.contentDocument.body.style.color = "rgba(255, 255, 255, 0.4)";
iframe.contentDocument.body.style.fontSize = "20px";
iframe.contentDocument.body.style.fontFamily = "Microsoft YaHei,Microsoft YaHei UI,Microsoft JhengHei,Microsoft JhengHei UI,Segoe UI,Lucida Grande,Helvetica,Arial,Noto Sans CJK SC,Droid Sans Fallback,Noto Sans Mono CJK SC,FreeSans,Arimo,Droid Sans,Hiragino Sans GB,Hiragino Sans GB W3,FontAwesome,PingFang SC,Source Han Sans CN,Wenquanyi Micro Hei,WenQuanYi Zen Hei,sans-serif";
iframe.contentDocument.body.style.transition = "all 0.3s linear";
setTimeout(function() {
iframe.contentDocument.body.innerHTML = "\u300a";
}, 800);
iframe.contentDocument.body.onclick = show_2_hide_1;
iframe.contentDocument.body.onmouseover = show_1;
iframe.contentDocument.body.onmouseout = hide_1;
iframe.contentDocument.body.onselectstart = function () {
return false;
};
iframe.contentDocument.body.onmousedown = function () {
return false;
};
iframe.contentDocument.body.onmouseup = function () {
return false;
};
iframe2.style.border = "none";
iframe2.style.border = "none";
iframe2.style.zIndex = 10001;
iframe2.style.height = "100%";
iframe2.style.width = "300px";
iframe2.style.position = "fixed";
iframe2.style.left = "100%";
iframe2.style.top = "0";
iframe2.style.backgroundColor = "rgba(0, 0, 0, 0.5)";
iframe2.style.transition = "all 0.3s";
document.body.appendChild(iframe2);
iframe2.contentDocument.body.style.whiteSpace = "pre";
iframe2.contentDocument.body.style.color = "#fff";
iframe2.contentDocument.body.style.lineHeight = "120%";
iframe2.contentDocument.body.style.fontSize = "0.8em";
iframe2.contentDocument.body.style.fontFamily = "Microsoft YaHei,Microsoft YaHei UI,Microsoft JhengHei,Microsoft JhengHei UI,Segoe UI,Lucida Grande,Helvetica,Arial,Noto Sans CJK SC,Droid Sans Fallback,Noto Sans Mono CJK SC,FreeSans,Arimo,Droid Sans,Hiragino Sans GB,Hiragino Sans GB W3,FontAwesome,PingFang SC,Source Han Sans CN,Wenquanyi Micro Hei,WenQuanYi Zen Hei,sans-serif";
var clickTime;
iframe2.contentDocument.body.onclick = function() {
var time = (new Date()).valueOf();
if (time - clickTime <= 500) {
show_1_hide_2();
clickTime = 0;
} else {
clickTime = time;
}
};
} else {
setTimeout(main, 100);
}
}
var show = false;
if (window.top == window) {
window.addEventListener('message', function(event) {
if (event.data == "audioVideoCapturerShow" && show == false) {
show = true;
iframe2 = document.createElement("iframe");
window.addEventListener('message', function(event) {
if (event.data[0] == "audioVideoCapturer") {
iframe2.contentDocument.body.innerHTML += event.data[1] + "\r\n";
}
});
main();
}
});
}
if (location.href.toLocaleLowerCase().indexOf("song") != -1 || location.href.toLocaleLowerCase().indexOf("audio") != -1 || location.href.toLocaleLowerCase().indexOf("music") != -1 || location.href.toLocaleLowerCase().indexOf("yinyue") != -1 || location.href.toLocaleLowerCase().indexOf("video") != -1 || location.href.toLocaleLowerCase().indexOf("movie") != -1 || location.href.toLocaleLowerCase().indexOf("film") != -1 || location.href.toLocaleLowerCase().indexOf("dianying") != -1) {
(function() {
var createObjectURLOriginal = URL.createObjectURL;
function createObjectURL(blob) {
/*
URL.createObjectURL = createObjectURLOriginal;
var ret = URL.createObjectURL(blob);
URL.createObjectURL = createObjectURL;
URL.revokeObjectURL(ret);
return ret;
*/
return undefined;
}
URL.createObjectURL = createObjectURL;
URL.createObjectURL.toString = function () {
return "function () { [native code] }";
};
})();
window.top.postMessage("audioVideoCapturerShow", '*');
}
})();