mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 21:00:23 +01:00
parent
040acb311f
commit
f73a4ee619
@ -23,6 +23,11 @@
|
|||||||
hideContainer: true,
|
hideContainer: true,
|
||||||
defaultValue: {}
|
defaultValue: {}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "expandStatus",
|
||||||
|
expandContainer: true,
|
||||||
|
defaultValue: {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "displayHiddenSettings",
|
name: "displayHiddenSettings",
|
||||||
defaultValue: false
|
defaultValue: false
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
const settings = {};
|
const settings = {};
|
||||||
let urlContainer;
|
let urlContainer;
|
||||||
let hideContainer;
|
let hideContainer;
|
||||||
|
let expandContainer;
|
||||||
|
|
||||||
function isDefinitionInvalid(settingDefinition, newValue){
|
function isDefinitionInvalid(settingDefinition, newValue){
|
||||||
if (newValue === undefined && settingDefinition.optional){
|
if (newValue === undefined && settingDefinition.optional){
|
||||||
@ -351,6 +352,40 @@
|
|||||||
});
|
});
|
||||||
settingDefinition.hideAble = false;
|
settingDefinition.hideAble = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settingDefinition.expandContainer){
|
||||||
|
expandContainer = settingDefinition;
|
||||||
|
let changeListeners = {};
|
||||||
|
settingDefinition.setExpandByName = function(name, value){
|
||||||
|
logging.verbose("set expand of", name, "to", value);
|
||||||
|
const expandStore = settingDefinition.get();
|
||||||
|
expandStore[name] = value;
|
||||||
|
settingDefinition.set(expandStore);
|
||||||
|
(changeListeners[name] || []).forEach(function(listener){
|
||||||
|
listener(value);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
settingDefinition.getExpandByName = function(name){
|
||||||
|
const expandStore = settingDefinition.get();
|
||||||
|
return expandStore[name] || false;
|
||||||
|
};
|
||||||
|
settingDefinition.onExpandChange = function(name, listener){
|
||||||
|
if (!changeListeners[name]){
|
||||||
|
changeListeners[name] = [];
|
||||||
|
}
|
||||||
|
changeListeners[name].push(listener);
|
||||||
|
};
|
||||||
|
settingDefinition.on(function(event){
|
||||||
|
const value = event.newValue;
|
||||||
|
Object.keys(value).forEach(function(name){
|
||||||
|
if (value[name]){
|
||||||
|
(changeListeners[name] || []).forEach(function(listener){
|
||||||
|
listener(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.getDefinition = function(name){
|
scope.getDefinition = function(name){
|
||||||
@ -366,7 +401,8 @@
|
|||||||
scope.getContainers = function(){
|
scope.getContainers = function(){
|
||||||
return {
|
return {
|
||||||
url: Object.create(urlContainer),
|
url: Object.create(urlContainer),
|
||||||
hide: Object.create(hideContainer)
|
hide: Object.create(hideContainer),
|
||||||
|
expand: Object.create(expandContainer)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@
|
|||||||
};
|
};
|
||||||
addSection();
|
addSection();
|
||||||
|
|
||||||
const {hide: hideContainer} = settings.getContainers();
|
const {hide: hideContainer, expand: expandContainer} = settings.getContainers();
|
||||||
settingsDisplay.forEach(function(display){
|
settingsDisplay.forEach(function(display){
|
||||||
if (typeof display === "string"){
|
if (typeof display === "string"){
|
||||||
addSection(display);
|
addSection(display);
|
||||||
@ -248,6 +248,7 @@
|
|||||||
}
|
}
|
||||||
if (setting){
|
if (setting){
|
||||||
setting.display = display;
|
setting.display = display;
|
||||||
|
|
||||||
let hideChangeListeners = [];
|
let hideChangeListeners = [];
|
||||||
setting.setHide = function setHide(value){
|
setting.setHide = function setHide(value){
|
||||||
if (hideContainer){
|
if (hideContainer){
|
||||||
@ -279,6 +280,31 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let expandChangeListeners = [];
|
||||||
|
setting.setExpand = function setExpand(value){
|
||||||
|
if (expandContainer){
|
||||||
|
expandContainer.setExpandByName(display.name, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
setting.onExpandChange = function(listener){
|
||||||
|
expandChangeListeners.push(listener);
|
||||||
|
};
|
||||||
|
setting.getExpand = function getExpand(){
|
||||||
|
if (expandContainer){
|
||||||
|
return expandContainer.getExpandByName(display.name);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (expandContainer){
|
||||||
|
expandContainer.onExpandChange(display.name, function(value){
|
||||||
|
expandChangeListeners.forEach(function(listener){
|
||||||
|
listener(value);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var row = optionsGui.createSettingRow(setting);
|
var row = optionsGui.createSettingRow(setting);
|
||||||
let section = lastSection;
|
let section = lastSection;
|
||||||
section.addRow(row);
|
section.addRow(row);
|
||||||
|
@ -198,14 +198,17 @@
|
|||||||
|
|
||||||
if (setting.urlSpecific && url === ""){
|
if (setting.urlSpecific && url === ""){
|
||||||
let container = document.createElement("div");
|
let container = document.createElement("div");
|
||||||
container.className = "urlValues collapsed";
|
container.className = "urlValues " + (setting.getExpand()? "expanded": "collapsed");
|
||||||
container.appendChild(input);
|
container.appendChild(input);
|
||||||
var collapser = document.createElement("span");
|
var collapser = document.createElement("span");
|
||||||
collapser.classList.add("collapser");
|
collapser.classList.add("collapser");
|
||||||
container.appendChild(collapser);
|
container.appendChild(collapser);
|
||||||
collapser.addEventListener("click", function(){
|
collapser.addEventListener("click", function(){
|
||||||
container.classList.toggle("collapsed");
|
setting.setExpand(!setting.getExpand());
|
||||||
container.classList.toggle("expanded");
|
});
|
||||||
|
setting.onExpandChange(function(value){
|
||||||
|
container.classList[value? "remove": "add"]("collapsed");
|
||||||
|
container.classList[value? "add": "remove"]("expanded");
|
||||||
});
|
});
|
||||||
let urlTable = document.createElement("table");
|
let urlTable = document.createElement("table");
|
||||||
let caption = document.createElement("caption");
|
let caption = document.createElement("caption");
|
||||||
|
@ -2,11 +2,13 @@ Version 0.5.4:
|
|||||||
changes:
|
changes:
|
||||||
- converted "API whitelist" to "protected API features" (automatic settings migration)
|
- converted "API whitelist" to "protected API features" (automatic settings migration)
|
||||||
- notification details are not stored by default
|
- notification details are not stored by default
|
||||||
|
- settings page reorganized
|
||||||
|
|
||||||
new features:
|
new features:
|
||||||
- added save/load directly to/from file option
|
- added save/load directly to/from file option
|
||||||
- added protection for DOMRect (getClientRects)
|
- added protection for DOMRect (getClientRects)
|
||||||
- added setting to control if notification details should be stored
|
- added setting to control if notification details should be stored
|
||||||
|
- state of the arrow for url specific values is saved
|
||||||
|
|
||||||
fixes:
|
fixes:
|
||||||
- window and audio API were always blocked when using any of the "block ..." modes
|
- window and audio API were always blocked when using any of the "block ..." modes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user