How arnoudkooi/sn-utils works
Project type and purpose
• Type: A browser extension (Chrome/Firefox/Edge/Safari) adding developer utilities to ServiceNow.
• Purpose: Inject UI panels (code search, snippet management, script sync, diff viewer, Monaco-based code editor) into ServiceNow pages; provide popup/options pages; coordinate across frames via background scripts.
File structure
• Top‐level “manifest.json” declares extension contexts: background scripts, content_scripts, browser_action (popup), sidepanel, options_page.
• “background.js”/“bgscriptmodern.js” run in the background (service worker/event page).
• “content_script_all_frames.js” & “content_script_parent.js” inject into SN frames.
• UI pages under project root: popup.html/js, sidepanel.html/js, codesearch.html/js, codeeditor.html/js, diff.html, scriptsync.html/js, snippets.html/js, viewdata.html/js, settingeditor.html, welcome.html.
• “css/” folder holds styles for each UI page.
• “js/monaco/” and subfolders embed the Monaco editor library.
• “publish/” manifests for other browsers.
• Supporting libs in “js/”: DataStream.js, Tinycon.js, datatables, moment, md5, instancetag, jquery.deserialize, etc.
README
• Confirms it is a ServiceNow utilities extension.
• No external backend—everything runs client-side within the browser.
• Mentions on-prem vs. hosted manifests.
Main components & their interactions
a. Manifest (manifest.json) – defines extension entry points and permissions (tabs, storage, activeTab, scripting).
b. Background scripts – listen for browser events (popup click, messages from content scripts), manage shared state/storage, route messages.
c. Content scripts – injected into ServiceNow pages (all frames & parent), detect ServiceNow environment, inject the sidepanel and interact with page DOM.
d. UI pages – popup.html (quick-access menu), sidepanel.html (embedded panel in SN layout), codesearch.html, codeeditor.html, diff.html, scriptsync.html, snippets.html, viewdata.html, settingeditor.html, welcome.html. Each page uses its CSS and JS to render UI, call extension APIs, exchange messages with background/content scripts.
e. Libraries – Monaco Editor (for code editing/diff), DataTables (for tables), Moment.js (datetime), md5, etc.
f. Assets – CSS, images, audio (alert.mp3), webfonts.
Architectural patterns & design principles
• Event-driven/messaging architecture using Chrome runtime.sendMessage/onMessage.
• Separation of concerns: background (logic & state), content (page integration), UI pages (presentation).
• Modular file layout: each UI feature in its own HTML/JS/CSS set.
• Reuse of common libraries (monaco, jQuery, DataTables).