Don't forget that checkboxes may have any value for checked and
unchecked -- they're Data Validation. So while it would be confusing
for someone who is viewing the values on the sheet, one can create a
checkbox where it is checked when the value is `false`, and
unchecked when the value is `true`.
You need to check the cell for a `DataValidationRule`, and then look
at its `CriteriaValues`:
function onEdit(e) {
var edited = e.range;
var rule = edited.getDataValidation();
if (rule && rule.getCriteriaType() ==
SpreadsheetApp.DataValidationCriteria.CHECKBOX) {
var choices = rule.getCriteriaValues();
if (!choices.length) {
choices = [true, false];
}
if (edited.value === choices[0]) {
// checked
} else if (edited.value === choices[1]) {
// unchecked
} else {
// cell probably has a DV error tooltip
}
}
}
I wrote about this a bit on SO:
https://stackoverflow.com/questions/54935257/finding-all-checkboxes-in-a-google-sheet