Skip to content

Commit

Permalink
Automatic option saving, removal of all HTM4, and minor formatting ch…
Browse files Browse the repository at this point in the history
…anges.

This commit makes no functional change, but will be released.
  • Loading branch information
aghorler committed Apr 11, 2018
1 parent 264c608 commit 03afd40
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 269 deletions.
122 changes: 61 additions & 61 deletions html/options.html
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
<!DOCTYPE html>
<html>
<head>
<title>WebRTC Leak Prevent</title>
</head>
<body>
<h3>Advanced options</h3>
<head>
<title>WebRTC Leak Prevent</title>
</head>
<body>
<h3>Advanced options</h3>

<div id="content">
<div id="new">
<p>
<strong>WebRTC IP handling policy</strong>
</p>
<p>
<label for="policy">IP handling policy:</label>
<select id="policy">
<option value="default_public_interface_only">Use the default public interface only</option>
<option value="default_public_and_private_interfaces">Use the default public interface and private interface</option>
<option value="disable_non_proxied_udp">Disable non-proxied UDP (force proxy)</option>
</select>
</p>
</div>
<div id="content">
<div id="new">
<p>
<strong>WebRTC IP handling policy</strong>
</p>
<p>
<label for="policy">IP handling policy:</label>
<select id="policy">
<option value="default_public_interface_only">Use the default public interface only</option>
<option value="default_public_and_private_interfaces">Use the default public interface and private interface</option>
<option value="disable_non_proxied_udp">Disable non-proxied UDP (force proxy)</option>
</select>
</p>
</div>

<div id="legacy">
<p>
<strong>Legacy options</strong>
</p>
<p>
<input type="checkbox" id="multipleroutes">
<label for="multipleroutes">Prevent WebRTC from using routes other than the default route.</label><br>
<em>(Supported from Chromium version 42, and depreciated from version 48)</em>
</p>
<p id="legacyProxy">
<input type="checkbox" id="proxy">
<label for="proxy">Prevent WebRTC from using non-proxied UDP.</label><br>
<em>(Supported from Chromium version 47, and depreciated from version 48)</em>
</p>
</div>
<div id="legacy">
<p>
<strong>Legacy options</strong>
</p>
<p>
<input type="checkbox" id="multipleroutes">
<label for="multipleroutes">Prevent WebRTC from using routes other than the default route.</label><br>
<em>(Supported from Chromium version 42, and depreciated from version 48)</em>
</p>
<p id="legacyProxy">
<input type="checkbox" id="proxy">
<label for="proxy">Prevent WebRTC from using non-proxied UDP.</label><br>
<em>(Supported from Chromium version 47, and depreciated from version 48)</em>
</p>
</div>

<p>
<a href="https://github.com/aghorler/WebRTC-Leak-Prevent/blob/master/DOCUMENTATION.md#what-do-the-settings-mean-and-do"><em>What do these options mean?</em></a>
</p>
</div>
<p>
<a href="https://github.com/aghorler/WebRTC-Leak-Prevent/blob/master/DOCUMENTATION.md#what-do-the-settings-mean-and-do"><em>What do these options mean?</em></a>
</p>
</div>

<div id="fail">
<p align="center" style="color:red">This version of Chromium is incompatible with the required WebRTC privacy options.</p>
</div>
<div id="fail">
<p style="color:red; text-align: center;">This version of Chromium is incompatible with the required WebRTC privacy options.</p>
</div>

<div id="incognito">
<strong>Incognito protection</strong>

<p id="incognitoAllowed" style="color:green;">Enabled</p>

<p id="incognitoDisallowed" style="color:red;">
Not enabled. <a style="color:red;" href="https://github.com/aghorler/WebRTC-Leak-Prevent/blob/master/DOCUMENTATION.md#what-is-incognito-protection"><i>Learn more.</i></a>
</p>
</div>
<div id="incognito">
<strong>Incognito protection</strong>

<p>
<span id="applyButton">
<button id="save">Apply settings</button>
</span>
<p id="incognitoAllowed" style="color:green;">Enabled</p>

<span id="status"></span>
</p>
<p id="incognitoDisallowed" style="color:red;">
Not enabled. <a style="color:red;" href="https://github.com/aghorler/WebRTC-Leak-Prevent/blob/master/DOCUMENTATION.md#what-is-incognito-protection"><i>Learn more.</i></a>
</p>
</div>

<p align="center" style="color:grey">
Developed by Aaron Horler (aghorler) | <a href="https://github.com/aghorler/WebRTC-Leak-Prevent">GitHub source</a>
</p>
<p>
<span id="applyButton">
<button id="save">Apply settings</button>
</span>

<script src="/js/options.js"></script>
</body>
<span id="status"></span>
</p>

<p style="color:grey; text-align: center;">
Developed by Aaron Horler (aghorler) | <a href="https://github.com/aghorler/WebRTC-Leak-Prevent">GitHub source</a>
</p>

<script src="/js/options.js"></script>
</body>
</html>
82 changes: 41 additions & 41 deletions js/background.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
/* Function to get version of Chrome. https://stackoverflow.com/a/4900484 */
function getMajorVerison(){
var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
return raw ? parseInt(raw[2], 10) : false;
var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
return raw ? parseInt(raw[2], 10) : false;
}

/* Configure WebRTC leak prevention default setting, depending on Chrome version. */
chrome.storage.local.get(null, function(items){
/* Use webRTCIPHandlingPolicy in newer versions of Chrome. */
if(getMajorVerison() > 47){
if(items.rtcIPHandling == undefined){
try{
chrome.storage.local.set({
rtcIPHandling: 'default_public_interface_only'
}, function(){
chrome.privacy.network.webRTCIPHandlingPolicy.set({
value: 'default_public_interface_only'
});
})
}
catch(e){
console.log("Error: " + e.message);
}
}
}
/* Use webRTCMultipleRoutesEnabled in older versions of Chrome. */
else if(getMajorVerison() > 41 && getMajorVerison() < 48){
if(items.rtcMultipleRoutes == undefined){
try{
chrome.storage.local.set({
rtcMultipleRoutes: true
}, function(){
chrome.privacy.network.webRTCMultipleRoutesEnabled.set({
value: false,
scope: 'regular'
});
})
}
catch(e){
console.log("Error: " + e.message);
}
}
}
/* Use webRTCIPHandlingPolicy in newer versions of Chrome. */
if(getMajorVerison() > 47){
if(items.rtcIPHandling == undefined){
try{
chrome.storage.local.set({
rtcIPHandling: 'default_public_interface_only'
}, function(){
chrome.privacy.network.webRTCIPHandlingPolicy.set({
value: 'default_public_interface_only'
});
})
}
catch(e){
console.log("Error: " + e.message);
}
}
}
/* Use webRTCMultipleRoutesEnabled in older versions of Chrome. */
else if(getMajorVerison() > 41 && getMajorVerison() < 48){
if(items.rtcMultipleRoutes == undefined){
try{
chrome.storage.local.set({
rtcMultipleRoutes: true
}, function(){
chrome.privacy.network.webRTCMultipleRoutesEnabled.set({
value: false,
scope: 'regular'
});
})
}
catch(e){
console.log("Error: " + e.message);
}
}
}
});

/* Open options page on install. */
chrome.runtime.onInstalled.addListener(function(details){
if(details.reason == "install"){
chrome.runtime.openOptionsPage();
}
if(details.reason == "install"){
chrome.runtime.openOptionsPage();
}
});

/* Open options page on toolbar icon click. */
chrome.browserAction.onClicked.addListener(function(){
chrome.runtime.openOptionsPage();
chrome.runtime.openOptionsPage();
});
Loading

0 comments on commit 03afd40

Please sign in to comment.