This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
le-h5.user.js
80 lines (59 loc) · 2.11 KB
/
le-h5.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// ==UserScript==
// @name le-h5
// @namespace https://github.com/gooyie/le-h5
// @homepageURL https://github.com/gooyie/le-h5
// @supportURL https://github.com/gooyie/le-h5/issues
// @updateURL https://raw.githubusercontent.com/gooyie/le-h5/master/le-h5.user.js
// @version 0.1.0
// @description letv html5 player
// @author gooyie
// @license MIT License
//
// @include *://*.le.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
class Hooker {
static hookCall(cb = ()=>{}) {
const call = Function.prototype.call;
Function.prototype.call = function(...args) {
let ret = call.bind(this)(...args);
if (args) cb(...args);
return ret;
};
Function.prototype.call.toString = Function.prototype.call.toLocaleString = function() {
return 'function call() { [native code] }';
};
}
static _isFactoryCall(args) { // module.exports, module, module.exports, require
return args.length === 4 && 'object' === typeof args[1] && args[1].hasOwnProperty('exports');
}
static hookFactoryCall(cb = ()=>{}) {
this.hookCall((...args) => {if (this._isFactoryCall(args)) cb(...args);});
}
static _isH5adFactoryCall(exports = {}) {
return 'function' === typeof exports && exports.prototype.hasOwnProperty('refreshAd');
}
static hookH5ad(cb = ()=>{}) {
this.hookFactoryCall((...args) => {if (this._isH5adFactoryCall(args[1].exports)) cb(args[1]);});
}
}
class Faker {
static fakeMacSafari() {
const UA_MAC_SAFARI = "macintosh safari";
Object.defineProperty(navigator, 'userAgent', {get: () => UA_MAC_SAFARI});
}
}
class Mocker {
static mock() {
Faker.fakeMacSafari();
this.hackH5ad();
}
static hackH5ad() {
Hooker.hookH5ad(module => module.exports = null);
}
}
Mocker.mock();
})();