Add "Automatically open crowd-sourced destinations in a new tab" option

This commit is contained in:
Tim "timmyRS" Speckhals 2019-09-13 05:01:41 +02:00
parent c461f30066
commit 8b2ea8188e
5 changed files with 45 additions and 17 deletions

View File

@ -41,6 +41,9 @@
"optionsCrowdBypass": {
"message": "Give and take the destinations of unbypassable shorteners."
},
"optionsCrowdAutoOpen": {
"message": "Automatically open crowd-sourced destinations in a new tab."
},
"privacyPolicy": {
"message": "Privacy Policy"
},

View File

@ -41,8 +41,8 @@ brws.runtime.onInstalled.addListener(details=>{
})
//Keeping track of options
var enabled=true,instantNavigation=false,trackerBypassEnabled=true,instantNavigationTrackers=false,blockIPLoggers=true,crowdEnabled=true,userscript=""
brws.storage.sync.get(["disable","navigation_delay","no_tracker_bypass","no_instant_navigation_trackers","allow_ip_loggers","crowd_bypass_opt_out"],res=>{
var enabled=true,instantNavigation=false,trackerBypassEnabled=true,instantNavigationTrackers=false,blockIPLoggers=true,crowdEnabled=true,crowdAutoOpen=false,userscript=""
brws.storage.sync.get(["disable","navigation_delay","no_tracker_bypass","no_instant_navigation_trackers","allow_ip_loggers","crowd_bypass_opt_out","crowd_auto_open"],res=>{
if(res)
{
enabled=(!res.disable||res.disable!=="true")
@ -58,10 +58,11 @@ brws.storage.sync.get(["disable","navigation_delay","no_tracker_bypass","no_inst
}})
}
instantNavigation=(res.navigation_delay==0)
trackerBypassEnabled=(!res.no_tracker_bypass||res.no_tracker_bypass!=="true")
instantNavigationTrackers=(!res.no_instant_navigation_trackers||res.no_instant_navigation_trackers!=="true")
blockIPLoggers=(!res.allow_ip_loggers||res.allow_ip_loggers!=="true")
crowdEnabled=(!res.crowd_bypass_opt_out||res.crowd_bypass_opt_out!=="true")
trackerBypassEnabled=(res.no_tracker_bypass!=="true")
instantNavigationTrackers=(res.no_instant_navigation_trackers!=="true")
blockIPLoggers=(res.allow_ip_loggers!=="true")
crowdEnabled=(res.crowd_bypass_opt_out!=="true")
crowdAutoOpen=(res.crowd_auto_open==="true")
}
})
brws.storage.local.get(["userscript"],res=>{
@ -117,6 +118,10 @@ brws.storage.onChanged.addListener(changes=>{
{
crowdEnabled=(changes.crowd_bypass_opt_out.newValue!=="true")
}
if(changes.crowd_auto_open)
{
crowdAutoOpen=(changes.crowd_auto_open.newValue==="true")
}
if(changes.userscript)
{
userscript=changes.userscript.newValue
@ -194,6 +199,14 @@ brws.webRequest.onBeforeRequest.addListener(details=>{
return encodedRedirect(details.url.substr(52))
},{types:["main_frame"],urls:["https://universal-bypass.org/before-navigate?target=*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(crowdAutoOpen)
{
const args=new URLSearchParams(details.url.substr(43))
if(args.has("target")&&args.has("back"))
{
brws.tabs.create({url:args.get("target")})
}
}
return {redirectUrl:brws.runtime.getURL("html/crowd-bypassed.html")+details.url.substr(43)}
},{types:["main_frame"],urls:["https://universal-bypass.org/crowd-bypassed?*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{

View File

@ -1,12 +1,12 @@
let params=new URLSearchParams(location.search)
if(params.has("target")&&params.has("back"))
const args=new URLSearchParams(location.search)
if(args.has("target")&&args.has("back"))
{
let i=document.querySelector('[data-message="crowdBypassedInfo"]')
i.innerHTML=i.innerHTML.replace("%",'<a></a>')
let a=i.querySelector("a")
a.setAttribute("target","_blank")
a.href=a.textContent=params.get("target")
document.getElementById("ignore").href=params.get("back")+"#ignoreCrowdBypass"
a.href=a.textContent=args.get("target")
document.getElementById("ignore").href=args.get("back")+"#ignoreCrowdBypass"
}
else
{

View File

@ -16,7 +16,8 @@
<input type="checkbox" id="option-tracker-bypass"> <label for="option-tracker-bypass"><span data-message="optionsTrackerBypass"></span> (Bit.ly, Goo.gl, T.co, ...)</label> (<a href="https://apimon.de/privacy" target="_blank" data-message="privacyPolicy"></a>)<br>
<input type="checkbox" id="option-instant-navigation-trackers"> <label for="option-instant-navigation-trackers" data-message="optionsInstantNavigationTrackers"></label><br>
<input type="checkbox" id="option-block-ip-loggers"> <label for="option-block-ip-loggers" data-message="optionsBlockIPLoggers"></label><br>
<input type="checkbox" id="option-crowd-bypass"> <label for="option-crowd-bypass" data-message="optionsCrowdBypass"></label> (<a href="https://github.com/timmyrs/Universal-Bypass/blob/master/PRIVACY.md" target="_blank" data-message="privacyPolicy"></a>)
<input type="checkbox" id="option-crowd-bypass"> <label for="option-crowd-bypass" data-message="optionsCrowdBypass"></label> (<a href="https://github.com/timmyrs/Universal-Bypass/blob/master/PRIVACY.md" target="_blank" data-message="privacyPolicy"></a>)<br>
<input type="checkbox" id="option-crowd-auto-open"> <label for="option-crowd-auto-open" data-message="optionsCrowdAutoOpen"></label>
</ul>
<h2 data-message="optionsUserscripts"></h2>
<a name="userscripts"></a>

View File

@ -7,9 +7,10 @@ navigationDelayCheckbox=document.getElementById("navigation-delay-toggle"),
trackerBypassCheckbox=document.getElementById("option-tracker-bypass"),
instantNavigationTrackersCheckbox=document.getElementById("option-instant-navigation-trackers"),
blockIPLoggersCheckbox=document.getElementById("option-block-ip-loggers"),
crowdBypassCheckbox=document.getElementById("option-crowd-bypass")
crowdBypassCheckbox=document.getElementById("option-crowd-bypass"),
crowdAutoOpenCheckbox=document.getElementById("option-crowd-auto-open")
var navigationDelayInputTimer
brws.storage.sync.get(["disable","navigation_delay","no_tracker_bypass","no_instant_navigation_trackers","allow_ip_loggers","crowd_bypass_opt_out"],res=>{
brws.storage.sync.get(["disable","navigation_delay","no_tracker_bypass","no_instant_navigation_trackers","allow_ip_loggers","crowd_bypass_opt_out","crowd_auto_open"],res=>{
if(res==undefined)
{
res={}
@ -32,22 +33,26 @@ brws.storage.sync.get(["disable","navigation_delay","no_tracker_bypass","no_inst
navigationDelayInput.value=res.navigation_delay
navigationDelayCheckbox.setAttribute("checked","checked")
}
if(!res.no_tracker_bypass||res.no_tracker_bypass!=="true")
if(res.no_tracker_bypass!=="true")
{
trackerBypassCheckbox.setAttribute("checked","checked")
}
if(!res.no_instant_navigation_trackers||res.no_instant_navigation_trackers!=="true")
if(res.no_instant_navigation_trackers!=="true")
{
instantNavigationTrackersCheckbox.setAttribute("checked","checked")
}
if(!res.allow_ip_loggers||res.allow_ip_loggers!=="true")
if(res.allow_ip_loggers!=="true")
{
blockIPLoggersCheckbox.setAttribute("checked","checked")
}
if(!res.crowd_bypass_opt_out||res.crowd_bypass_opt_out!=="true")
if(res.crowd_bypass_opt_out!=="true")
{
crowdBypassCheckbox.setAttribute("checked","checked")
}
if(res.crowd_auto_open==="true")
{
crowdAutoOpenCheckbox.setAttribute("checked","checked")
}
instantNavigationTrackersLogic()
enabledCheckbox.onchange=function()
{
@ -102,6 +107,12 @@ brws.storage.sync.get(["disable","navigation_delay","no_tracker_bypass","no_inst
crowd_bypass_opt_out:(!this.checked).toString()
})
}
crowdAutoOpenCheckbox.onchange=function()
{
brws.storage.sync.set({
crowd_auto_open:this.checked.toString()
})
}
})
function instantNavigationTrackersLogic()
{