This script lock range and works fine. But if you edit locked cell, it locks locked cell again. How to control it?
`function onEdit(e){
let protection = e.range.protect();
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
}function onEdit(e){
if (e.value == null){
let prot = SpreadsheetApp.getActiveSheet().getProtections(SpreadsheetApp.ProtectionType.RANGE);
for (let i in prot){
if (prot[i].getRange().getA1Notation() == e.range.getA1Notation())
prot[i].remove();
}
} else {
let protection = e.range.protect();
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit())
protection.setDomainEdit(false);
}}`