Logger that optionally mirror to a on-page UI overlay shared by every page match-common userscript
Tento skript by nemal byť nainštalovaný priamo. Je to knižnica pre ďalšie skripty, ktorú by mali používať cez meta príkaz // @require https://update.greasyfork.org/scripts/588114/1882370/Logging%20Handler%20%20UI%20Overlay.js
One logging call, two sinks: the browser console and a translucent, click-through log panel pinned to the top-right of the page.
LoggingUI.create) for @requiren scripts on a page therefore produce one panel, not n stacked copies.console.debug/info/warn/errorToggle scoping:
Persistence is best-effort. GM_getValue and GM_setValue are used when the calling script granted them; without the grants the toggles simply live for the lifetime of the page.
// @require https://update.greasyfork.org/...
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
const logger = LoggingUI.create({
name: '$NAME', // console prefix
tag: 'gcr', // panel prefix
console: true, // default console mirror
panel: true, // default panel visibility
panelSink: !IS_PROFILE, // this instance may write
});
logger.registerMenuCommands(); // optional: two GM menu toggles
logger.info('feed seeded with %d comments', n);
logger.warn('poll failed:', err);
| method(s) | note |
|---|---|
| logger.debug | info |
| logger.log(...args) | alias of info |
| logger.consoleEnabled | getter/setter (boolean) |
| logger.panelEnabled | getter/setter (boolean, page-wide) |
| logger.toggleConsole() / togglePanel() | flip and persist, returns new state |
| logger.registerMenuCommands(opts) | register the two GM menu toggles |
| logger.clear() | empty the shared panel |
| logger.element | the panel node, or null |