Skip to content

Commit

Permalink
added browser masking feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli Mitchell committed Mar 18, 2012
1 parent 8ef2fab commit 139144c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 4 deletions.
1 change: 1 addition & 0 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<preference name="display-reports-by" value="domain" /> <!--either "domain" or "page"-->
<preference name="prefixr" value="true" />
<preference name="prefixr-exclude" value="[]" />
<preference name="browser-id" value="opera" />

<access origin="*" subdomains="true" />
</widget>
37 changes: 36 additions & 1 deletion includes/patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,39 @@ if ( widget.preferences.getItem('prefixr') != 'false' ) {
userJSEvent.cssText = userJSEvent.cssText.replace(/(-o-[^;]+;\s*)\1+/gim,"$1");
}
}, false);
}
}

(function() {
if (widget.preferences.getItem('browser-id') && typeof window.navigator != 'undefined') {
if (widget.preferences.getItem('browser-id').search(/(ie|firefox|chrome)/i) > -1) {
var navigator = window.navigator,
platform = navigator.userAgent.match(/\((.*?);/);

if (platform.length > 1) platform = platform[1];
else platform = 'Windows NT 6.1';

window.opera = false;

switch (widget.preferences.getItem('browser-id')) {
case 'ie' : // mask as IE
navigator.appName = 'Microsoft Internet Explorer'
navigator.appVersion = '5.0 (compatible; MSIE 9.0; ' +platform+ '; Trident/5.0;)'
navigator.userAgent = 'Mozilla/5.0 (compatible; MSIE 9.0; ' +platform+ '; Trident/5.0)'
break;
case 'firefox' : // mask as Firefox
navigator.appName = 'Netscape'
navigator.appVersion = '5.0 (' +platform+ ')'
navigator.product = 'Gecko'
navigator.userAgent = 'Mozilla/5.0 (' +platform+ '; rv:10.0.2) Gecko/20100101 Firefox/10.0.2'
break;
case 'chrome' :
navigator.appName = 'Netscape'
navigator.appVersion = '5.0 (' +platform+ ') AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1068.1 Safari/536.3'
navigator.product = 'Gecko'
navigator.vendor = 'Google Inc.'
navigator.userAgent = 'Mozilla/5.0 (' +platform+ ') AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1068.1 Safari/536.3'
break;
}
}
}
})();
34 changes: 31 additions & 3 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@
#columnize {
min-height:190px;
}

label[for=as-opera], input:checked + label[for=as-opera] {color: red}
label[for=as-ie], input:checked + label[for=as-ie] {color: blue}
label[for=as-firefox], input:checked + label[for=as-firefox] {color: orange}
label[for=as-chrome], input:checked + label[for=as-chrome] {color: green}
</style>
</head>
<body>
Expand Down Expand Up @@ -330,7 +335,7 @@ <h1>Fix the Web <span class="light"> Options</span></h1>
</label>
</p>
<div class="sub_section">
Automatically make CSS3 properties coded for other browsers <strong><a href="https://addons.opera.com/addons/extensions/details/css-prefixr">work in Opera too</a></strong>?
Make CSS3 properties coded for other browsers <strong><a href="https://addons.opera.com/addons/extensions/details/css-prefixr" title="Feature derived from Christoph142's CSS3 Prefixr extension">work in Opera too</a></strong>?
<input type="radio" name="prefixr" value="true" id="prefixr-on" />
<label for="prefixr-on">
<strong>Enable</strong>
Expand All @@ -345,6 +350,29 @@ <h1>Fix the Web <span class="light"> Options</span></h1>
<textarea name="prefixr-exclude" id="prefixr-exclude" cols="60" rows="7" title="one site per line; don't include the protocol (e.g. http://)" placeholder="exclude.com"></textarea>
</div>
</div>
<div class="sub_section">
Browser Identification (<abbr title="Will mask Javascript properties as the selected browser. However, the user-agent string sent in the HTTP request can not be masked by the extension. To do that, right-click the page, select Edit Site Preferences..., and go to Network &gt; Browser Identification">about</abbr>):

<input type="radio" name="browser-id" value="opera" id="as-opera" />
<label for="as-opera">
<strong>Opera (default)</strong>
</label>

<input type="radio" name="browser-id" value="ie" id="as-ie" />
<label for="as-ie">
<strong>Internet Explorer</strong>
</label>

<input type="radio" name="browser-id" value="firefox" id="as-firefox" />
<label for="as-firefox">
<strong>Firefox</strong>
</label>

<input type="radio" name="browser-id" value="chrome" id="as-chrome" />
<label for="as-chrome">
<strong>Chrome</strong>
</label>
</div>
</form>
<!--
</section>
Expand Down Expand Up @@ -498,9 +526,9 @@ <h4>Thanks:</h4>
} catch(e) {}
} else widget.preferences.setItem('prefixr-exclude', '[]')
} else field.value = widget.preferences.getItem(field.name)

field.addEventListener("change", savePrefs, false);
}

field.addEventListener("change", savePrefs, false);
}

updateIntervalValue();
Expand Down

0 comments on commit 139144c

Please sign in to comment.