From e39ad68d2617f94fdac0af083cc8143d5b857140 Mon Sep 17 00:00:00 2001 From: wanhose Date: Thu, 20 Jan 2022 15:30:09 +0100 Subject: [PATCH] feat(scripts): improve content script --- scripts/content.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/scripts/content.js b/scripts/content.js index 81d32e8..13e74ac 100644 --- a/scripts/content.js +++ b/scripts/content.js @@ -93,20 +93,23 @@ const fix = () => { if (hostname.includes(match)) { switch (action) { - case "click": - const submit = document.querySelector(selector); - submit?.click?.(); - break; - case "reset": + case "click": { const node = document.querySelector(selector); - node?.style?.setProperty?.(property, "initial", "important"); - break; - case "resetAll": + node?.click(); + } + case "remove": { + const node = document.querySelector(selector); + node?.style?.removeProperty(property); + } + case "reset": { + const node = document.querySelector(selector); + node?.style?.setProperty(property, "initial", "important"); + } + case "resetAll": { const nodes = document.querySelectorAll(selector); - nodes.forEach((node) => - node?.style?.setProperty?.(property, "initial", "important") - ); - break; + // prettier-ignore + nodes.forEach((node) => node?.style?.setProperty(property, "initial", "important")); + } default: break; }