puppeteer-pro 2.5.2 → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -88
- package/index.d.ts +1 -29
- package/index.d.ts.map +1 -1
- package/index.js +3 -157
- package/index.js.map +1 -1
- package/package.json +10 -12
- package/plugins/anonymize.user.agent/index.d.ts +2 -1
- package/plugins/anonymize.user.agent/index.d.ts.map +1 -1
- package/plugins/anonymize.user.agent/index.js +4 -4
- package/plugins/anonymize.user.agent/index.js.map +1 -1
- package/plugins/avoid.detection/index.d.ts +2 -1
- package/plugins/avoid.detection/index.d.ts.map +1 -1
- package/plugins/avoid.detection/index.js +1 -1
- package/plugins/avoid.detection/index.js.map +1 -1
- package/plugins/block.resources/index.d.ts +1 -1
- package/plugins/block.resources/index.d.ts.map +1 -1
- package/plugins/block.resources/index.js +1 -1
- package/plugins/block.resources/index.js.map +1 -1
- package/plugins/disable.dialogs/index.d.ts +1 -1
- package/plugins/disable.dialogs/index.d.ts.map +1 -1
- package/plugins/disable.dialogs/index.js +1 -1
- package/plugins/disable.dialogs/index.js.map +1 -1
- package/plugins/index.d.ts +30 -0
- package/plugins/index.d.ts.map +1 -0
- package/plugins/index.js +159 -0
- package/plugins/index.js.map +1 -0
- package/plugins/manage.cookies/index.d.ts +1 -1
- package/plugins/manage.cookies/index.d.ts.map +1 -1
- package/plugins/manage.cookies/index.js +4 -3
- package/plugins/manage.cookies/index.js.map +1 -1
- package/plugins/manage.localstorage/index.d.ts +1 -1
- package/plugins/manage.localstorage/index.d.ts.map +1 -1
- package/plugins/manage.localstorage/index.js +4 -3
- package/plugins/manage.localstorage/index.js.map +1 -1
- package/plugins/shared.d.ts +7 -0
- package/plugins/shared.d.ts.map +1 -0
- package/plugins/shared.js +23 -0
- package/plugins/shared.js.map +1 -0
- package/plugins/solve.recaptchas/index.d.ts +2 -1
- package/plugins/solve.recaptchas/index.d.ts.map +1 -1
- package/plugins/solve.recaptchas/index.js +3 -2
- package/plugins/solve.recaptchas/index.js.map +1 -1
- package/plugins/solve.recaptchas/injections/utils.js +144 -144
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
module.exports = async (audioUrl) => {
|
|
2
|
-
// Credit to https://github.com/dessant/buster
|
|
3
|
-
const normalizeAudio = async function (buffer) {
|
|
4
|
-
const ctx = new AudioContext();
|
|
5
|
-
const audioBuffer = await ctx.decodeAudioData(buffer);
|
|
6
|
-
ctx.close();
|
|
7
|
-
|
|
8
|
-
const offlineCtx = new OfflineAudioContext(1, audioBuffer.duration * 16000, 16000);
|
|
9
|
-
const source = offlineCtx.createBufferSource();
|
|
10
|
-
source.connect(offlineCtx.destination);
|
|
11
|
-
source.buffer = audioBuffer;
|
|
12
|
-
source.start();
|
|
13
|
-
|
|
14
|
-
return offlineCtx.startRendering();
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const sliceAudio = function ({ audioBuffer, start, end }) {
|
|
18
|
-
const sampleRate = audioBuffer.sampleRate;
|
|
19
|
-
const channels = audioBuffer.numberOfChannels;
|
|
20
|
-
|
|
21
|
-
const startOffset = sampleRate * start;
|
|
22
|
-
const endOffset = sampleRate * end;
|
|
23
|
-
const frameCount = endOffset - startOffset;
|
|
24
|
-
|
|
25
|
-
const ctx = new AudioContext();
|
|
26
|
-
const audioSlice = ctx.createBuffer(channels, frameCount, sampleRate);
|
|
27
|
-
ctx.close();
|
|
28
|
-
|
|
29
|
-
const tempArray = new Float32Array(frameCount);
|
|
30
|
-
for (var channel = 0; channel < channels; channel++) {
|
|
31
|
-
audioBuffer.copyFromChannel(tempArray, channel, startOffset);
|
|
32
|
-
audioSlice.copyToChannel(tempArray, channel, 0);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return audioSlice;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// Credit to https://github.com/Jam3/audiobuffer-to-wav
|
|
39
|
-
const audioBufferToWav = function (buffer, opt) {
|
|
40
|
-
opt = opt || {};
|
|
41
|
-
|
|
42
|
-
var numChannels = buffer.numberOfChannels;
|
|
43
|
-
var sampleRate = buffer.sampleRate;
|
|
44
|
-
var format = opt.float32 ? 3 : 1;
|
|
45
|
-
var bitDepth = format === 3 ? 32 : 16;
|
|
46
|
-
|
|
47
|
-
var result;
|
|
48
|
-
if (numChannels === 2) {
|
|
49
|
-
result = _.interleave(buffer.getChannelData(0), buffer.getChannelData(1));
|
|
50
|
-
} else {
|
|
51
|
-
result = buffer.getChannelData(0);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return _.encodeWAV(result, format, sampleRate, numChannels, bitDepth);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const _ = {
|
|
58
|
-
encodeWAV: (samples, format, sampleRate, numChannels, bitDepth) => {
|
|
59
|
-
var bytesPerSample = bitDepth / 8;
|
|
60
|
-
var blockAlign = numChannels * bytesPerSample;
|
|
61
|
-
|
|
62
|
-
var buffer = new ArrayBuffer(44 + samples.length * bytesPerSample);
|
|
63
|
-
var view = new DataView(buffer);
|
|
64
|
-
|
|
65
|
-
/* RIFF identifier */
|
|
66
|
-
_.writeString(view, 0, 'RIFF');
|
|
67
|
-
/* RIFF chunk length */
|
|
68
|
-
view.setUint32(4, 36 + samples.length * bytesPerSample, true);
|
|
69
|
-
/* RIFF type */
|
|
70
|
-
_.writeString(view, 8, 'WAVE');
|
|
71
|
-
/* format chunk identifier */
|
|
72
|
-
_.writeString(view, 12, 'fmt ');
|
|
73
|
-
/* format chunk length */
|
|
74
|
-
view.setUint32(16, 16, true);
|
|
75
|
-
/* sample format (raw) */
|
|
76
|
-
view.setUint16(20, format, true);
|
|
77
|
-
/* channel count */
|
|
78
|
-
view.setUint16(22, numChannels, true);
|
|
79
|
-
/* sample rate */
|
|
80
|
-
view.setUint32(24, sampleRate, true);
|
|
81
|
-
/* byte rate (sample rate * block align) */
|
|
82
|
-
view.setUint32(28, sampleRate * blockAlign, true);
|
|
83
|
-
/* block align (channel count * bytes per sample) */
|
|
84
|
-
view.setUint16(32, blockAlign, true);
|
|
85
|
-
/* bits per sample */
|
|
86
|
-
view.setUint16(34, bitDepth, true);
|
|
87
|
-
/* data chunk identifier */
|
|
88
|
-
_.writeString(view, 36, 'data');
|
|
89
|
-
/* data chunk length */
|
|
90
|
-
view.setUint32(40, samples.length * bytesPerSample, true);
|
|
91
|
-
if (format === 1) { // Raw PCM
|
|
92
|
-
_.floatTo16BitPCM(view, 44, samples);
|
|
93
|
-
} else {
|
|
94
|
-
_.writeFloat32(view, 44, samples);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return buffer;
|
|
98
|
-
},
|
|
99
|
-
interleave: (inputL, inputR) => {
|
|
100
|
-
var length = inputL.length + inputR.length;
|
|
101
|
-
var result = new Float32Array(length);
|
|
102
|
-
|
|
103
|
-
var index = 0;
|
|
104
|
-
var inputIndex = 0;
|
|
105
|
-
|
|
106
|
-
while (index < length) {
|
|
107
|
-
result[index++] = inputL[inputIndex];
|
|
108
|
-
result[index++] = inputR[inputIndex];
|
|
109
|
-
inputIndex++;
|
|
110
|
-
}
|
|
111
|
-
return result;
|
|
112
|
-
},
|
|
113
|
-
writeFloat32: (output, offset, input) => {
|
|
114
|
-
for (var i = 0; i < input.length; i++, offset += 4) {
|
|
115
|
-
output.setFloat32(offset, input[i], true);
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
floatTo16BitPCM: (output, offset, input) => {
|
|
119
|
-
for (var i = 0; i < input.length; i++, offset += 2) {
|
|
120
|
-
var s = Math.max(-1, Math.min(1, input[i]));
|
|
121
|
-
output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7FFF, true);
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
writeString: (view, offset, string) => {
|
|
125
|
-
for (var i = 0; i < string.length; i++) {
|
|
126
|
-
view.setUint8(offset + i, string.charCodeAt(i));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const audioResponse = await fetch(audioUrl, { referrer: '' });
|
|
132
|
-
const audio = await audioResponse.arrayBuffer();
|
|
133
|
-
|
|
134
|
-
const _audioBuffer = await normalizeAudio(audio);
|
|
135
|
-
|
|
136
|
-
const audioSlice = sliceAudio({
|
|
137
|
-
audioBuffer: _audioBuffer,
|
|
138
|
-
start: 1.5,
|
|
139
|
-
end: _audioBuffer.duration - 1.5
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
const wav = audioBufferToWav(audioSlice);
|
|
143
|
-
|
|
144
|
-
return [...new Int8Array(wav)];
|
|
1
|
+
module.exports = async (audioUrl) => {
|
|
2
|
+
// Credit to https://github.com/dessant/buster
|
|
3
|
+
const normalizeAudio = async function (buffer) {
|
|
4
|
+
const ctx = new AudioContext();
|
|
5
|
+
const audioBuffer = await ctx.decodeAudioData(buffer);
|
|
6
|
+
ctx.close();
|
|
7
|
+
|
|
8
|
+
const offlineCtx = new OfflineAudioContext(1, audioBuffer.duration * 16000, 16000);
|
|
9
|
+
const source = offlineCtx.createBufferSource();
|
|
10
|
+
source.connect(offlineCtx.destination);
|
|
11
|
+
source.buffer = audioBuffer;
|
|
12
|
+
source.start();
|
|
13
|
+
|
|
14
|
+
return offlineCtx.startRendering();
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const sliceAudio = function ({ audioBuffer, start, end }) {
|
|
18
|
+
const sampleRate = audioBuffer.sampleRate;
|
|
19
|
+
const channels = audioBuffer.numberOfChannels;
|
|
20
|
+
|
|
21
|
+
const startOffset = sampleRate * start;
|
|
22
|
+
const endOffset = sampleRate * end;
|
|
23
|
+
const frameCount = endOffset - startOffset;
|
|
24
|
+
|
|
25
|
+
const ctx = new AudioContext();
|
|
26
|
+
const audioSlice = ctx.createBuffer(channels, frameCount, sampleRate);
|
|
27
|
+
ctx.close();
|
|
28
|
+
|
|
29
|
+
const tempArray = new Float32Array(frameCount);
|
|
30
|
+
for (var channel = 0; channel < channels; channel++) {
|
|
31
|
+
audioBuffer.copyFromChannel(tempArray, channel, startOffset);
|
|
32
|
+
audioSlice.copyToChannel(tempArray, channel, 0);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return audioSlice;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Credit to https://github.com/Jam3/audiobuffer-to-wav
|
|
39
|
+
const audioBufferToWav = function (buffer, opt) {
|
|
40
|
+
opt = opt || {};
|
|
41
|
+
|
|
42
|
+
var numChannels = buffer.numberOfChannels;
|
|
43
|
+
var sampleRate = buffer.sampleRate;
|
|
44
|
+
var format = opt.float32 ? 3 : 1;
|
|
45
|
+
var bitDepth = format === 3 ? 32 : 16;
|
|
46
|
+
|
|
47
|
+
var result;
|
|
48
|
+
if (numChannels === 2) {
|
|
49
|
+
result = _.interleave(buffer.getChannelData(0), buffer.getChannelData(1));
|
|
50
|
+
} else {
|
|
51
|
+
result = buffer.getChannelData(0);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return _.encodeWAV(result, format, sampleRate, numChannels, bitDepth);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const _ = {
|
|
58
|
+
encodeWAV: (samples, format, sampleRate, numChannels, bitDepth) => {
|
|
59
|
+
var bytesPerSample = bitDepth / 8;
|
|
60
|
+
var blockAlign = numChannels * bytesPerSample;
|
|
61
|
+
|
|
62
|
+
var buffer = new ArrayBuffer(44 + samples.length * bytesPerSample);
|
|
63
|
+
var view = new DataView(buffer);
|
|
64
|
+
|
|
65
|
+
/* RIFF identifier */
|
|
66
|
+
_.writeString(view, 0, 'RIFF');
|
|
67
|
+
/* RIFF chunk length */
|
|
68
|
+
view.setUint32(4, 36 + samples.length * bytesPerSample, true);
|
|
69
|
+
/* RIFF type */
|
|
70
|
+
_.writeString(view, 8, 'WAVE');
|
|
71
|
+
/* format chunk identifier */
|
|
72
|
+
_.writeString(view, 12, 'fmt ');
|
|
73
|
+
/* format chunk length */
|
|
74
|
+
view.setUint32(16, 16, true);
|
|
75
|
+
/* sample format (raw) */
|
|
76
|
+
view.setUint16(20, format, true);
|
|
77
|
+
/* channel count */
|
|
78
|
+
view.setUint16(22, numChannels, true);
|
|
79
|
+
/* sample rate */
|
|
80
|
+
view.setUint32(24, sampleRate, true);
|
|
81
|
+
/* byte rate (sample rate * block align) */
|
|
82
|
+
view.setUint32(28, sampleRate * blockAlign, true);
|
|
83
|
+
/* block align (channel count * bytes per sample) */
|
|
84
|
+
view.setUint16(32, blockAlign, true);
|
|
85
|
+
/* bits per sample */
|
|
86
|
+
view.setUint16(34, bitDepth, true);
|
|
87
|
+
/* data chunk identifier */
|
|
88
|
+
_.writeString(view, 36, 'data');
|
|
89
|
+
/* data chunk length */
|
|
90
|
+
view.setUint32(40, samples.length * bytesPerSample, true);
|
|
91
|
+
if (format === 1) { // Raw PCM
|
|
92
|
+
_.floatTo16BitPCM(view, 44, samples);
|
|
93
|
+
} else {
|
|
94
|
+
_.writeFloat32(view, 44, samples);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return buffer;
|
|
98
|
+
},
|
|
99
|
+
interleave: (inputL, inputR) => {
|
|
100
|
+
var length = inputL.length + inputR.length;
|
|
101
|
+
var result = new Float32Array(length);
|
|
102
|
+
|
|
103
|
+
var index = 0;
|
|
104
|
+
var inputIndex = 0;
|
|
105
|
+
|
|
106
|
+
while (index < length) {
|
|
107
|
+
result[index++] = inputL[inputIndex];
|
|
108
|
+
result[index++] = inputR[inputIndex];
|
|
109
|
+
inputIndex++;
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
},
|
|
113
|
+
writeFloat32: (output, offset, input) => {
|
|
114
|
+
for (var i = 0; i < input.length; i++, offset += 4) {
|
|
115
|
+
output.setFloat32(offset, input[i], true);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
floatTo16BitPCM: (output, offset, input) => {
|
|
119
|
+
for (var i = 0; i < input.length; i++, offset += 2) {
|
|
120
|
+
var s = Math.max(-1, Math.min(1, input[i]));
|
|
121
|
+
output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7FFF, true);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
writeString: (view, offset, string) => {
|
|
125
|
+
for (var i = 0; i < string.length; i++) {
|
|
126
|
+
view.setUint8(offset + i, string.charCodeAt(i));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const audioResponse = await fetch(audioUrl, { referrer: '' });
|
|
132
|
+
const audio = await audioResponse.arrayBuffer();
|
|
133
|
+
|
|
134
|
+
const _audioBuffer = await normalizeAudio(audio);
|
|
135
|
+
|
|
136
|
+
const audioSlice = sliceAudio({
|
|
137
|
+
audioBuffer: _audioBuffer,
|
|
138
|
+
start: 1.5,
|
|
139
|
+
end: _audioBuffer.duration - 1.5
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const wav = audioBufferToWav(audioSlice);
|
|
143
|
+
|
|
144
|
+
return [...new Int8Array(wav)];
|
|
145
145
|
};
|