ar fixed, disabling/enabling sites roughly works.
This commit is contained in:
parent
d079a84005
commit
13a928b90e
@ -71,8 +71,6 @@ var _sc_sites = {
|
||||
|
||||
var _sc_init = async function(){
|
||||
|
||||
StorageManager.delopt("uw-siteopts");
|
||||
|
||||
var newSettings = await StorageManager.getopt_async("uw-siteopts");
|
||||
|
||||
if (Debug.debug)
|
||||
@ -142,6 +140,7 @@ function inIframe(){
|
||||
}
|
||||
|
||||
var _sc_isEnabled = function(site){
|
||||
// console.log(".... — _sc_sites[", site, "].status:", (_sc_sites[site] == undefined ? "<default>" : _sc_sites[site].status), "; Settings.extensionMode:", Settings.extensionMode)
|
||||
if( inIframe ) {
|
||||
return _sc_siteEnableEmbedded(site);
|
||||
}
|
||||
@ -150,12 +149,12 @@ var _sc_isEnabled = function(site){
|
||||
|
||||
var _sc_siteEnabled = function(site){
|
||||
|
||||
if(Debug.debug)
|
||||
console.log("[SitesConf::_sc_siteEnabled] checking", site, "in", _sc_sites, ":", _sc_sites[site]);
|
||||
|
||||
// če za stran nismo določili načina delovanja, potem storimo privzeto stvar
|
||||
// if we haven't defined options for a site, we do the default thing
|
||||
if( _sc_sites[site] == undefined || _sc_sites[site].status == "follow-global"){
|
||||
|
||||
console.log(".... this site is undefined!");
|
||||
|
||||
if ( Settings.extensionMode == "blacklist" ){
|
||||
return true;
|
||||
}
|
||||
@ -173,13 +172,16 @@ var _sc_siteEnabled = function(site){
|
||||
return false;
|
||||
}
|
||||
|
||||
var _sc_siteStatus = function(site){
|
||||
if( _sc_sites[site] == undefined)
|
||||
return "follow-global";
|
||||
return _sc_sites[site].status;
|
||||
}
|
||||
|
||||
var _sc_arEnabled = function(site){
|
||||
|
||||
if(Debug.debug)
|
||||
console.log("[SitesConf::_sc_arEnabled] checking", site, "in", _sc_sites, ":", _sc_sites[site]);
|
||||
|
||||
if( _sc_sites[site] == undefined || _sc_sites[site].arStatus == "follow-global" ){
|
||||
if(Settings.arDetect.mode == "blacklist" ){
|
||||
if(Settings.extensionMode == "blacklist" ){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -192,13 +194,18 @@ var _sc_arEnabled = function(site){
|
||||
return false;
|
||||
}
|
||||
|
||||
var _sc_arStatus = function(site){
|
||||
if( _sc_sites[site] == undefined )
|
||||
return "follow-global";
|
||||
return _sc_sites[site].arStatus;
|
||||
}
|
||||
|
||||
var _sc_siteEnableEmbedded = function(site) {
|
||||
|
||||
if(Debug.debug)
|
||||
console.log("[SitesConf::_sc_arEnableEmbedded] checking", site, "in", _sc_sites, ":", _sc_sites[site].statusEmbedded);
|
||||
|
||||
if( _sc_sites[site] == undefined || _sc_sites[site].statusEmbedded == "follow-global" ){
|
||||
if(Settings.arDetect.mode == "blacklist" ){
|
||||
console.log(".... this site is undefined! er");
|
||||
|
||||
if(Settings.extensionMode == "blacklist" ){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -255,6 +262,9 @@ var SitesConf = {
|
||||
reload: _sc_reload,
|
||||
save: _sc_save,
|
||||
updateSiteStatus: _sc_updateSiteStatus,
|
||||
updateSite: _sc_updateSiteStatus,
|
||||
getSiteStatus: _sc_siteStatus,
|
||||
getArStatus: _sc_arStatus,
|
||||
siteEnabled: _sc_siteEnabled,
|
||||
isEnabled: _sc_isEnabled,
|
||||
siteEnableEmbedded: _sc_siteEnableEmbedded,
|
||||
|
38
js/uw-bg.js
38
js/uw-bg.js
@ -140,7 +140,13 @@ function _uwbg_rcvmsg(message, sender, sendResponse){
|
||||
var config = {};
|
||||
config.videoAlignment = Settings.miscFullscreenSettings.videoFloat;
|
||||
config.arConf = {};
|
||||
config.arConf.enabled_global = Settings.arDetect.enabled == "global";
|
||||
config.arConf.enabled_global = Settings.arDetect.enabled == "blacklist";
|
||||
|
||||
config.site = {};
|
||||
config.site.status = SitesConf.getSiteStatus(BgVars.currentSite);
|
||||
config.site.arStatus = SitesConf.getArStatus(BgVars.currentSite);
|
||||
|
||||
config.mode = Settings.extensionMode;
|
||||
|
||||
if(Debug.debug)
|
||||
console.log("[uw-bg::_uwbg_rcvmsg] Keybinds.getKeybinds() returned this:", Keybinds.getKeybinds());
|
||||
@ -150,7 +156,7 @@ function _uwbg_rcvmsg(message, sender, sendResponse){
|
||||
|
||||
// predvidevajmo, da je enako. Če je drugače, bomo popravili ko dobimo odgovor
|
||||
// assume current is same as global & change that when you get response from content script
|
||||
config.arConf.enabled_current = Settings.arDetect.enabled == "global";
|
||||
config.arConf.enabled_current = Settings.arDetect.enabled == "blacklist";
|
||||
|
||||
var res = {response: config}
|
||||
if(BrowserDetect.firefox){
|
||||
@ -173,19 +179,8 @@ function _uwbg_rcvmsg(message, sender, sendResponse){
|
||||
}
|
||||
|
||||
else if(message.cmd == "uw-enabled-for-site"){
|
||||
var wlindex = Settings.whitelist.indexOf(BgVars.currentSite);
|
||||
var blindex = Settings.blacklist.indexOf(BgVars.currentSite);
|
||||
|
||||
var mode = "default";
|
||||
if(wlindex > -1)
|
||||
mode = "whitelist";
|
||||
if(blindex > -1)
|
||||
mode = "blacklist";
|
||||
|
||||
if(Debug.debug){
|
||||
console.log("[uw::receiveMessage] is this site: ", BgVars.currentSite, "\n\n", "whitelisted or blacklisted? whitelist:", (wlindex > -1), "; blacklist:", (blindex > -1), "; mode (return value):", mode, "\nwhitelist:",Settings.whitelist,"\nblacklist:",Settings.blacklist);
|
||||
|
||||
}
|
||||
var mode = SitesConf.getSiteStatus(BgVars.currentSite);
|
||||
|
||||
if(BrowserDetect.usebrowser == "firefox")
|
||||
return Promise.resolve({response: mode});
|
||||
@ -198,20 +193,7 @@ function _uwbg_rcvmsg(message, sender, sendResponse){
|
||||
return true;
|
||||
}
|
||||
else if(message.cmd == "enable-for-site"){
|
||||
var wlindex = Settings.whitelist.indexOf(BgVars.currentSite);
|
||||
var blindex = Settings.blacklist.indexOf(BgVars.currentSite);
|
||||
|
||||
if(wlindex > -1)
|
||||
Settings.whitelist.splice(BgVars.currentSite, 1);
|
||||
if(blindex > -1)
|
||||
Settings.blacklist.splice(BgVars.currentSite, 1);
|
||||
|
||||
if(message.option == "whitelist")
|
||||
Settings.whitelist.push(BgVars.currentSite);
|
||||
if(message.option == "blacklist")
|
||||
Settings.blacklist.push(BgVars.currentSite);
|
||||
|
||||
Settings.save();
|
||||
SitesConf.updateSite(BgVars.currentSite, {status: message.option, statusEmbedded: message.option});
|
||||
}
|
||||
|
||||
}
|
||||
|
1
js/uw.js
1
js/uw.js
@ -177,6 +177,7 @@ function receiveMessage(message, sender, sendResponse) {
|
||||
config.arConf = {};
|
||||
config.arConf.enabled_global = Settings.arDetect.enabled == "global";
|
||||
|
||||
|
||||
var keybinds = Keybinds.getKeybinds();
|
||||
if(Debug.debug)
|
||||
console.log("[uw-bg::_uwbg_rcvmsg] Keybinds.fetch returned this:", keybinds);
|
||||
|
@ -152,6 +152,28 @@ function loadConfig(config){
|
||||
|
||||
_config = config;
|
||||
|
||||
console.log(".... site status, config mode:", config.site.status, config.mode);
|
||||
|
||||
document.getElementById("current-site-status-global-status").innerHTML = config.mode == "blacklist" ? "<span style='color: #1f4'>allow</span>" : "<span style='color: #f00'>deny</span>";
|
||||
|
||||
if(config.site.status == "blacklisted" || (config.site.status == "follow-global" && config.mode == "whitelist") ){
|
||||
openMenu("thisSite");
|
||||
|
||||
// document.getElementById("current-site-blacklisted").classList.remove("hidden");
|
||||
// if(config.mode == "whitelist"){
|
||||
// document.getElementById("current-site-whitelist-only").classList.remove("hidden");
|
||||
// }
|
||||
|
||||
document.getElementById("extensionEnabledCurrentSite_blacklisted").setAttribute("checked","checked");
|
||||
}
|
||||
else if(config.site.status == "whitelisted"){
|
||||
document.getElementById("extensionEnabledCurrentSite_whitelisted").setAttribute("checked","checked");
|
||||
}
|
||||
else {
|
||||
document.getElementById("extensionEnabledCurrentSite_followGlobal").setAttribute("checked","checked");
|
||||
}
|
||||
|
||||
|
||||
// process video alignment:
|
||||
if(config.videoAlignment){
|
||||
for(var button in ArPanel.alignment)
|
||||
|
@ -193,11 +193,13 @@
|
||||
</div>
|
||||
|
||||
<div id="settings-for-current-site" class="suboption hidden">
|
||||
<p>Allow this extension to run on this site?</p>
|
||||
<!-- <p class="current-site-status" id="current-site-blacklisted">This site is currently blacklisted.</p> -->
|
||||
<!-- <p class="current-site-status" id="current-site-whitelist-only">Extension is set to only work on sites that have been whitelisted.</p> -->
|
||||
<p>Allow this extension to run on this site? <small><br/>NOTE: changes take effect after reload!</small></p>
|
||||
<form action="" name="extensionEnabledOnCurrentSite">
|
||||
<input type="radio" class="extensionEnabledOnCurrentSite" name="mode" value="default" > Follow global rules<br/>
|
||||
<input type="radio" class="extensionEnabledOnCurrentSite" name="mode" value="whitelist" > Always (whitelist)<br/>
|
||||
<input type="radio" class="extensionEnabledOnCurrentSite" name="mode" value="blacklist" > Never (blacklist)<br/>
|
||||
<input type="radio" class="extensionEnabledOnCurrentSite" name="mode" id="extensionEnabledCurrentSite_followGlobal" value="follow-global" > Follow default rules (currently: <span id="current-site-status-global-status"></span>)<br/>
|
||||
<input type="radio" class="extensionEnabledOnCurrentSite" name="mode" id="extensionEnabledCurrentSite_whitelisted" value="whitelisted" > Allow (whitelist this site) <br/>
|
||||
<input type="radio" class="extensionEnabledOnCurrentSite" name="mode" id="extensionEnabledCurrentSite_blacklisted" value="blacklisted" > Deny (blacklist this site)<br/>
|
||||
</form>
|
||||
<small>NOTE: this settings <b>don't</b> apply to videos embedded from other sites. This option takes effect after page reload.</small>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user