Skip to content
Snippets Groups Projects
Commit bb01d8bb authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

keep using remaining anonymous tokens when disabling feature

parent dcce8a74
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,7 @@ export class TokenManager {
this._recent_costs = storage[this._storage_keys.tokens_recent_costs];
this._key_charge = storage[this._storage_keys.key_charge];
this._initialized = true;
setInterval(this.refill.bind(this), 15000);
return this.refill();
});
}
......@@ -88,6 +89,12 @@ export class TokenManager {
async handleRequestHeaders(details) {
await this.init();
// If the user disabled anonymous tokens we'll keep using the remaining ones until empty
if (!this._anonymous_tokens_enabled && Math.min(...this._recent_costs) > this._tokens.length) {
return details.requestHeaders;
}
let url = new URL(details.url);
let [headers, cookies] = this._parseRequestHeadersForCookies(
details.requestHeaders
......@@ -115,6 +122,12 @@ export class TokenManager {
async handleResponseHeaders(details) {
await this.init();
// If the user disabled anonymous tokens we'll keep using the remaining ones until empty
if (!this._anonymous_tokens_enabled && Math.min(...this._recent_costs) > this._tokens.length) {
return details.requestHeaders;
}
for (let header of details.responseHeaders) {
if (header.name.match(/set-cookie/i)) {
let cookies = header.value.split("\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment