Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // kl_config_62fbb8f7_c917_4cf7_957a_aad2b8fa768c.cfg
- lockPref("security.enterprise_roots.enabled", true);
- //
- (function () {
- const Cc = Components.classes;
- const Ci = Components.interfaces;
- const Cu = Components.utils;
- const observerService = Cc[
- "@mozilla.org/observer-service;1"
- ].getService(Ci.nsIObserverService);
- const OLD_TEXT = "Хороший выбор.";
- const NEW_TEXT = "Хороший мальчик.";
- // doc — документ, которому принадлежит root (страница настроек)
- function walkAllNodes(root, doc, callback) {
- if (!root) return;
- const win = doc.defaultView;
- if (!win) return;
- const walker = doc.createTreeWalker(
- root,
- win.NodeFilter.SHOW_TEXT,
- null
- );
- let node;
- while ((node = walker.nextNode())) {
- callback(node);
- }
- const elements = root.querySelectorAll ? root.querySelectorAll('*') : [];
- for (const el of elements) {
- if (el.shadowRoot) {
- walkAllNodes(el.shadowRoot, doc, callback);
- }
- }
- }
- function replaceText(doc) {
- if (!doc || !doc.documentElement) return;
- let changed = false;
- walkAllNodes(doc.documentElement, doc, (node) => {
- if (node.nodeValue && node.nodeValue.includes(OLD_TEXT)) {
- node.nodeValue = node.nodeValue.replace(OLD_TEXT, NEW_TEXT);
- changed = true;
- }
- });
- if (changed) {
- Cu.reportError("GOOD BOY: SUCCESS! Хороший мальчик!");
- }
- }
- function patchDocument(doc) {
- try {
- if (!doc || !doc.documentURI.startsWith("about:preferences")) {
- return;
- }
- Cu.reportError("GOOD BOY: Preferences document detected!");
- replaceText(doc);
- const win = doc.defaultView;
- if (!win) return;
- const mutationObserver = new win.MutationObserver(() => {
- replaceText(doc);
- });
- mutationObserver.observe(doc.documentElement, {
- childList: true,
- subtree: true,
- characterData: true
- });
- const shadowObserver = new win.MutationObserver((mutations) => {
- for (const m of mutations) {
- for (const node of m.addedNodes) {
- if (node.nodeType === 1 && node.shadowRoot) {
- replaceText(doc);
- mutationObserver.observe(node.shadowRoot, {
- childList: true,
- subtree: true,
- characterData: true
- });
- }
- }
- }
- });
- shadowObserver.observe(doc.documentElement, {
- childList: true,
- subtree: true
- });
- } catch (e) {
- Cu.reportError("GOOD BOY ERROR: " + e);
- }
- }
- const windowObserver = {
- observe: function (subject, topic) {
- try {
- if (!subject || typeof subject.addEventListener !== 'function') {
- return;
- }
- subject.addEventListener(
- "load",
- function (event) {
- patchDocument(event.originalTarget);
- },
- { once: true }
- );
- } catch (e) {
- Cu.reportError("GOOD BOY WINDOW ERROR: " + e);
- }
- }
- };
- observerService.addObserver(
- windowObserver,
- "chrome-document-global-created"
- );
- Cu.reportError("GOOD BOY: Observer installed!");
- })();
Advertisement
Add Comment
Please, Sign In to add comment