-
Notifications
You must be signed in to change notification settings - Fork 1
/
hololive_fc_get_m3u8.user.js
57 lines (52 loc) · 1.72 KB
/
hololive_fc_get_m3u8.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// ==UserScript==
// @name Hololive FC get m3u8 url
// @description get m3u8 url on Hololive FC
// @version 1.0.0
// @include https://hololive-fc.com/live/*
// @include https://hololive-fc.com/video/*
// @run-at document-start
// ==/UserScript==
'use strict';
const xml_http_request = 'xml_http_request';
const xml_http_response = 'xml_http_response';
function trigger(name, data) {
var event = new CustomEvent(name, {
'detail': data
});
return document.dispatchEvent(event);
}
function initXMLHttpRequest() {
const open = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function (...args) {
const send = this.send;
const _this = this;
let post_data = [];
this.send = function (...data) {
post_data = data;
return send.apply(_this, data);
}
trigger(xml_http_request, args);
this.addEventListener('readystatechange', function () {
if (this.readyState === 4) {
const config = {
url: args[1],
status: this.status,
method: args[0],
data: post_data
};
trigger(xml_http_response, { config, response: this.response });
}
}, false);
return open.apply(this, args);
}
}
initXMLHttpRequest();
document.addEventListener(xml_http_request, (event) => {
const [method, url] = event.detail;
if (url.includes(".m3u8")) {
console.log(xml_http_request, event.detail);
const div = document.createElement("div");
div.innerHTML = url;
document.getElementById("player").insertAdjacentElement('afterend', div);
}
});