Skip to content
This repository was archived by the owner on Nov 15, 2017. It is now read-only.

Commit 48737a8

Browse files
committed
this fixes #344
1 parent 65142db commit 48737a8

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

js/storage.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ HTTPSB.loadUserSettings = function() {
6161
delete store.subframeFgColor;
6262

6363
HTTPSB.userSettings = store;
64+
65+
// https://github.com/gorhill/httpswitchboard/issues/344
66+
HTTPSB.userAgentSpoofer.shuffle();
6467
};
6568

6669
chrome.storage.local.get(this.userSettings, settingsLoaded);

js/useragent.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
/******************************************************************************/
2323

24-
(function() {
24+
HTTPSB.userAgentSpoofer = (function() {
2525

2626
/******************************************************************************/
2727

@@ -60,6 +60,7 @@ var userAgentSpoofer = function() {
6060
}
6161
};
6262

63+
// Prime spoofer
6364
userAgentSpoofer();
6465

6566
/******************************************************************************/
@@ -68,6 +69,10 @@ HTTPSB.asyncJobs.add('userAgentSwitcher', null, userAgentSpoofer, 120 * 1000, tr
6869

6970
/******************************************************************************/
7071

72+
return {
73+
shuffle: userAgentSpoofer
74+
};
75+
7176
})();
7277

7378
/******************************************************************************/

js/usersettings.js

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,40 @@ function changeUserSettings(name, value) {
3737
return httpsb.userSettings[name];
3838
}
3939

40+
// Pre-change
4041
switch ( name ) {
41-
// Need to visit each pageStats object to resize ring buffer
42-
case 'maxLoggedRequests':
43-
value = Math.max(Math.min(value, 500), 0);
44-
httpsb.userSettings[name] = value;
45-
var pageStats = httpsb.pageStats;
46-
for ( var pageUrl in pageStats ) {
47-
if ( pageStats.hasOwnProperty(pageUrl) ) {
48-
pageStats[pageUrl].requests.resizeLogBuffer(value);
49-
}
42+
43+
case 'maxLoggedRequests':
44+
value = Math.max(Math.min(value, 500), 0);
45+
break;
46+
47+
default:
48+
break;
49+
}
50+
51+
// Change
52+
httpsb.userSettings[name] = value;
53+
54+
// Post-change
55+
switch ( name ) {
56+
57+
// Need to visit each pageStats object to resize ring buffer
58+
case 'maxLoggedRequests':
59+
var pageStats = httpsb.pageStats;
60+
for ( var pageUrl in pageStats ) {
61+
if ( pageStats.hasOwnProperty(pageUrl) ) {
62+
pageStats[pageUrl].requests.resizeLogBuffer(value);
5063
}
51-
break;
64+
}
65+
break;
66+
67+
// https://github.com/gorhill/httpswitchboard/issues/344
68+
case 'spoofUserAgentWith':
69+
HTTPSB.userAgentSpoofer.shuffle();
70+
break;
5271

53-
default:
54-
httpsb.userSettings[name] = value;
55-
break;
72+
default:
73+
break;
5674
}
5775

5876
httpsb.saveUserSettings();

0 commit comments

Comments
 (0)