mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-30 23:38:47 +01:00
Improved audio API protection
reduced detection more consistent faking
This commit is contained in:
parent
ee02c8b999
commit
91b814ce7e
@ -89,8 +89,17 @@
|
||||
const floatCache = Object.create(null);
|
||||
const intCache = Object.create(null);
|
||||
|
||||
function arrayHasAnyNonZero(array){
|
||||
for (var i = 0, l = array.length; i < l; i += 1){
|
||||
if (array[i]){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function fakeFloat32Array(array, window, prefs){
|
||||
if (prefs("protectAudio", window.location)){
|
||||
if (arrayHasAnyNonZero(array)){
|
||||
let cached = false;
|
||||
let hash;
|
||||
if (prefs("useAudioCache")){
|
||||
@ -113,6 +122,7 @@
|
||||
});
|
||||
if (prefs("useAudioCache")){
|
||||
floatCache[hash] = new window.Float32Array(array);
|
||||
floatCache[hashing(array)] = new window.Float32Array(array);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -121,7 +131,7 @@
|
||||
}
|
||||
}
|
||||
function fakeUint8Array(array, window, prefs){
|
||||
if (prefs("protectAudio", window.location)){
|
||||
if (arrayHasAnyNonZero(array)){
|
||||
let cached = false;
|
||||
let hash;
|
||||
if (prefs("useAudioCache")){
|
||||
@ -136,6 +146,7 @@
|
||||
});
|
||||
if (prefs("useAudioCache")){
|
||||
intCache[hash] = new window.Uint8Array(array);
|
||||
intCache[hashing(array)] = new window.Uint8Array(array);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -236,9 +247,13 @@
|
||||
return function copyFromChannel(destination, channelNumber, startInChannel){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
var {prefs, notify, window, original} = check;
|
||||
notify("fakedAudioReadout");
|
||||
var channelData = this.getChannelData(channelNumber);
|
||||
if (!getChannelDataAlreadyFakedArrays.get(channelData)){
|
||||
notify("fakedAudioReadout");
|
||||
fakeFloat32Array(channelData, window, prefs);
|
||||
getChannelDataAlreadyFakedArrays.set(channelData, true);
|
||||
}
|
||||
var ret = original.apply(this, window.Array.from(args));
|
||||
fakeFloat32Array(destination, window, prefs);
|
||||
return ret;
|
||||
});
|
||||
};
|
||||
|
@ -1,9 +1,11 @@
|
||||
Version 0.5.8:
|
||||
changes:
|
||||
-
|
||||
- audio faking will not alter buffers with only zero values
|
||||
|
||||
new features:
|
||||
- Added cache for getChannelData
|
||||
- added combined cache for getChannelData and copyFromChannel:
|
||||
- better performance
|
||||
- prevent double faking => prevent detection
|
||||
|
||||
fixes:
|
||||
- after reset the hidden settings and expanded views were not reset
|
||||
|
Loading…
x
Reference in New Issue
Block a user