Skip to content

Commit

Permalink
Remove the UA quirks, that are not needed anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
tpopela committed May 18, 2018
1 parent 4585701 commit 3987bc2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
29 changes: 9 additions & 20 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015, 2016 Tomas Popela <[email protected]>
* Copyright (C) 2015-2017 Tomas Popela <[email protected]>
*
* Licensed under the GNU General Public License Version 2
*
Expand All @@ -23,28 +23,17 @@
// inspired with https://developer.chrome.com/extensions/webRequest
chrome.webRequest.onBeforeSendHeaders.addListener(
details => {
let anchor = document.createElement('a');
const headers = details.requestHeaders;
const headersLength = headers.length;

anchor.href = details.url;
/* It's not great that various sites are still so heavily dependant on
* the User-Agent..
* netflix.com - https://bugzilla.redhat.com/show_bug.cgi?id=1313244
* onenote.com - https://bugzilla.redhat.com/show_bug.cgi?id=1368571
*/
if (anchor.hostname !== 'www.netflix.com' &&
anchor.hostname !== 'www.onenote.com') {
const headers = details.requestHeaders;
const headersLength = headers.length;

for (let i = 0; i < headersLength; i++) {
if (headers[i].name === 'User-Agent') {
headers[i].value = headers[i].value.replace('; Linux', '; Fedora; Linux');
break;
}
for (let i = 0; i < headersLength; i++) {
if (headers[i].name === 'User-Agent') {
headers[i].value = headers[i].value.replace('; Linux', '; Fedora; Linux');
break;
}

return { requestHeaders: headers };
}

return { requestHeaders: headers };
},
{urls: ['<all_urls>']},
['blocking', 'requestHeaders']
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Fedora User Agent",
"description": "Modifies your User-Agent string to contain the name of Fedora Linux distribution.",
"version": "0.0.0.4",
"version": "0.0.0.5",
"permissions": [
"webRequest",
"webRequestBlocking",
Expand Down

0 comments on commit 3987bc2

Please sign in to comment.