This repository has been archived by the owner on Apr 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
/
intercept.js
94 lines (67 loc) · 2.23 KB
/
intercept.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
(function(){
const {changedFunctions} = require("./modifiedAPIs/canvas");
const {screenHandler} = require("./modifiedAPIs/screen");
const {whiteListHandler} = require("./modifiedAPIs/whitelist");
var utils = require('./Utils'),
undef,
wlInjectStates = {
'canvas': false,
'plugins': false,
'screen': false,
'winName': false,
'limitTab': false,
'date':false
};
exports.intercept = function intercept({subject: window},frameOptions){
var url = window.document.location.href;
//check if url is in whitelist and
//which script Injection options are to be whitelisted
// use the whitelist profile if site is in whitelist and
// whitelist is enabled and
// the default profile is not selected
if( utils.listCheck(url, wlInjectStates) == true)
whiteListHandler(window);
else{
// url is not whitelisted and profile is not default
// so we spoof vendor as usual
utils.defineProp(window,"Navigator","vendor",frameOptions.vendor);
}
if(wlInjectStates.canvas == false)
canvasHandler(window,frameOptions.canvas);
// blank out product sub property
utils.defineProp(window,"Navigator","productSub","");
if(frameOptions.plugins && wlInjectStates.plugins == false)
utils.defineProp(window,"Navigator","plugins","");
if(frameOptions.limitTab && wlInjectStates.limitTab == false)
utils.defineProp(window,"History","length","2");
if(wlInjectStates.screen == false)
screenHandler(window);
if (frameOptions.winName && wlInjectStates.winName == false)
window.name = "";
}
function canvasHandler(window,state){
var apiNames = Object.keys(changedFunctions);
apiNames.forEach (function(name){
var changedFunction = changedFunctions[name];
var original = window.wrappedJSObject[changedFunction.object].prototype[name];
Object.defineProperty(
window.wrappedJSObject[changedFunction.object].prototype,
name,
{
enumerable: true,
configureable: false,
get: function(){
if (!window.location.href){
return undef;
}
if(state == false)
return original;
// else if (state == true)
// return changedFunction.fake ;
else //block the canvas
return undef;
}
});
});
}
}());