mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-04-18 08:08:28 +02: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 floatCache = Object.create(null);
|
||||||
const intCache = 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){
|
function fakeFloat32Array(array, window, prefs){
|
||||||
if (prefs("protectAudio", window.location)){
|
if (arrayHasAnyNonZero(array)){
|
||||||
let cached = false;
|
let cached = false;
|
||||||
let hash;
|
let hash;
|
||||||
if (prefs("useAudioCache")){
|
if (prefs("useAudioCache")){
|
||||||
@ -113,6 +122,7 @@
|
|||||||
});
|
});
|
||||||
if (prefs("useAudioCache")){
|
if (prefs("useAudioCache")){
|
||||||
floatCache[hash] = new window.Float32Array(array);
|
floatCache[hash] = new window.Float32Array(array);
|
||||||
|
floatCache[hashing(array)] = new window.Float32Array(array);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -121,7 +131,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function fakeUint8Array(array, window, prefs){
|
function fakeUint8Array(array, window, prefs){
|
||||||
if (prefs("protectAudio", window.location)){
|
if (arrayHasAnyNonZero(array)){
|
||||||
let cached = false;
|
let cached = false;
|
||||||
let hash;
|
let hash;
|
||||||
if (prefs("useAudioCache")){
|
if (prefs("useAudioCache")){
|
||||||
@ -136,6 +146,7 @@
|
|||||||
});
|
});
|
||||||
if (prefs("useAudioCache")){
|
if (prefs("useAudioCache")){
|
||||||
intCache[hash] = new window.Uint8Array(array);
|
intCache[hash] = new window.Uint8Array(array);
|
||||||
|
intCache[hashing(array)] = new window.Uint8Array(array);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -236,9 +247,13 @@
|
|||||||
return function copyFromChannel(destination, channelNumber, startInChannel){
|
return function copyFromChannel(destination, channelNumber, startInChannel){
|
||||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||||
var {prefs, notify, window, original} = check;
|
var {prefs, notify, window, original} = check;
|
||||||
|
var channelData = this.getChannelData(channelNumber);
|
||||||
|
if (!getChannelDataAlreadyFakedArrays.get(channelData)){
|
||||||
notify("fakedAudioReadout");
|
notify("fakedAudioReadout");
|
||||||
|
fakeFloat32Array(channelData, window, prefs);
|
||||||
|
getChannelDataAlreadyFakedArrays.set(channelData, true);
|
||||||
|
}
|
||||||
var ret = original.apply(this, window.Array.from(args));
|
var ret = original.apply(this, window.Array.from(args));
|
||||||
fakeFloat32Array(destination, window, prefs);
|
|
||||||
return ret;
|
return ret;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
Version 0.5.8:
|
Version 0.5.8:
|
||||||
changes:
|
changes:
|
||||||
-
|
- audio faking will not alter buffers with only zero values
|
||||||
|
|
||||||
new features:
|
new features:
|
||||||
- Added cache for getChannelData
|
- added combined cache for getChannelData and copyFromChannel:
|
||||||
|
- better performance
|
||||||
|
- prevent double faking => prevent detection
|
||||||
|
|
||||||
fixes:
|
fixes:
|
||||||
- after reset the hidden settings and expanded views were not reset
|
- after reset the hidden settings and expanded views were not reset
|
||||||
|
Loading…
x
Reference in New Issue
Block a user