Skip to content

Instantly share code, notes, and snippets.

@mence
Created May 8, 2015 20:28
Show Gist options
  • Save mence/0a0edca79c830bcef27e to your computer and use it in GitHub Desktop.
Save mence/0a0edca79c830bcef27e to your computer and use it in GitHub Desktop.
Making the RescueTime Chrome Extension correctly report website usage in Chromium

Making the RescueTime extension work in Chromium

By default, the RescueTime Chrome extension doesn't report exact site usage because the extension determines browser usage by parsing the User Agent string in the request. So we need to fool the extension into thinking that we're using Chrome, not Chromium, which means it will accurately report usage statistics to RescueTime.

  1. Determine the extension's ID by visiting chrome://extensions
  2. If you have not done so before, check Developer mode in the top right.
  3. Locate the id of the RescueTime extension. It will look something like this: ID: bdakmnplckeopfghnlpocafcepegjeap
  4. Navigate to the Chromium extensions location on your machine: ~/Library/Application Support/Chromium/Default/Extensions/{extension_id}/3.0.18_0
  5. Edit RescueTimeUtil.js to return the browser as being Chrome. See the example in RescueTimeUtil.js in this gist.
getBrowser: function() {
if (this.browser == null) {
var v = this.getWindow().navigator.userAgent;
if (v.indexOf("Firefox/") > -1) {
this.browser = "firefox";
} else if (v.indexOf("Chrome/") > -1) {
this.browser = "chrome";
} else if (v.indexOf("Chromium/") > -1) {
this.browser = "chrome";
} else if (v.indexOf("Safari/") > -1) {
this.browser = "safari";
} else {
this.browser = "unknown";
}
}
return this.browser;
},
getBrowserVersion: function() {
if (this.browserVersion == null) {
if (this.getBrowser() == "firefox") {
this.browserVersion =
this.getWindow().navigator.userAgent.split("Firefox/")[1];
} else if (this.getBrowser() == "chrome") {
this.browserVersion =
this.getWindow().navigator.userAgent.split("Chrome/")[1].split(" ")[0];
} else if (this.getBrowser() == "chromium") {
this.browserVersion =
this.getWindow().navigator.userAgent.split("Chromium/")[1].split(" ")[0];
} else if (this.getBrowser() == "safari") {
this.browserVersion =
this.getWindow().navigator.userAgent.split("Version/")[1].split(" ")[0]
}
}
return this.browserVersion;
},
@RR1991
Copy link

RR1991 commented May 9, 2016

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment