diff options
author | hackademix | 2019-05-26 00:07:55 +0200 |
---|---|---|
committer | hackademix | 2019-05-26 00:07:55 +0200 |
commit | 78a5600d47e33cab4c1a65267172947b990e1a0e (patch) | |
tree | 471dec9d417a7766d1823cbf6f17c168faf3803b /src | |
parent | f11d4243bcec0fbeb059fe08bbd1c02fa0670a7a (diff) | |
download | noscript-78a5600d47e33cab4c1a65267172947b990e1a0e.tar.gz noscript-78a5600d47e33cab4c1a65267172947b990e1a0e.tar.xz noscript-78a5600d47e33cab4c1a65267172947b990e1a0e.zip |
Skip page autoreloads on transitions between temporary and permanent presets of the same kind.
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/ui.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/ui/ui.js b/src/ui/ui.js index 7e4d45d..c2e12b0 100644 --- a/src/ui/ui.js +++ b/src/ui/ui.js @@ -372,7 +372,7 @@ var UI = (() => { let customizer = target.closest(".customizer"); let row = customizer ? customizer.parentNode.querySelector("tr.customizing") : target.closest("tr.site"); if (!row) return; - row.temp2perm = false; + let isTemp = target.matches("input.temp"); let preset = target.matches("input.preset") ? target : customizer || isTemp ? row.querySelector("input.preset:checked") @@ -392,23 +392,25 @@ var UI = (() => { return; } - let policy = UI.policy; - let {siteMatch, contextMatch, perms} = row; - let presetValue = preset.value; - let policyPreset = presetValue.startsWith("T_") ? policy[presetValue.substring(2)].tempTwin : policy[presetValue]; - - if (policyPreset) { - if (row.perms !== policyPreset) { - row.temp2perm = row.perms && policyPreset.tempTwin === row.perms; - row.perms = policyPreset; - } - } + let {siteMatch, contextMatch, perms} = row; let isCap = customizer && target.matches(".cap"); let tempToggle = preset.parentNode.querySelector("input.temp"); if (ev.type === "change") { + row.temp2perm = false; + let policy = UI.policy; + let presetValue = preset.value; + let policyPreset = presetValue.startsWith("T_") ? policy[presetValue.substring(2)].tempTwin : policy[presetValue]; + + if (policyPreset) { + if (row.perms !== policyPreset) { + row.temp2perm = row.perms && + (policyPreset.tempTwin === row.perms || policyPreset === row.perms._tempTwin); + row.perms = policyPreset; + } + } if (preset.checked) { row.dataset.preset = preset.value; } |