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

Commit

Permalink
this fixes #344
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jun 18, 2014
1 parent 65142db commit 48737a8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
3 changes: 3 additions & 0 deletions js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ HTTPSB.loadUserSettings = function() {
delete store.subframeFgColor;

HTTPSB.userSettings = store;

// https://github.com/gorhill/httpswitchboard/issues/344
HTTPSB.userAgentSpoofer.shuffle();
};

chrome.storage.local.get(this.userSettings, settingsLoaded);
Expand Down
7 changes: 6 additions & 1 deletion js/useragent.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/******************************************************************************/

(function() {
HTTPSB.userAgentSpoofer = (function() {

/******************************************************************************/

Expand Down Expand Up @@ -60,6 +60,7 @@ var userAgentSpoofer = function() {
}
};

// Prime spoofer
userAgentSpoofer();

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

/******************************************************************************/

return {
shuffle: userAgentSpoofer
};

})();

/******************************************************************************/
Expand Down
44 changes: 31 additions & 13 deletions js/usersettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,40 @@ function changeUserSettings(name, value) {
return httpsb.userSettings[name];
}

// Pre-change
switch ( name ) {
// Need to visit each pageStats object to resize ring buffer
case 'maxLoggedRequests':
value = Math.max(Math.min(value, 500), 0);
httpsb.userSettings[name] = value;
var pageStats = httpsb.pageStats;
for ( var pageUrl in pageStats ) {
if ( pageStats.hasOwnProperty(pageUrl) ) {
pageStats[pageUrl].requests.resizeLogBuffer(value);
}

case 'maxLoggedRequests':
value = Math.max(Math.min(value, 500), 0);
break;

default:
break;
}

// Change
httpsb.userSettings[name] = value;

// Post-change
switch ( name ) {

// Need to visit each pageStats object to resize ring buffer
case 'maxLoggedRequests':
var pageStats = httpsb.pageStats;
for ( var pageUrl in pageStats ) {
if ( pageStats.hasOwnProperty(pageUrl) ) {
pageStats[pageUrl].requests.resizeLogBuffer(value);
}
break;
}
break;

// https://github.com/gorhill/httpswitchboard/issues/344
case 'spoofUserAgentWith':
HTTPSB.userAgentSpoofer.shuffle();
break;

default:
httpsb.userSettings[name] = value;
break;
default:
break;
}

httpsb.saveUserSettings();
Expand Down

0 comments on commit 48737a8

Please sign in to comment.