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,EAAQ,GACb,EAAO,OAAS,GAChB,EAAO,UAAU,EAAQ,CACrB,UAAW,QAGvB,EAEJ,QAAQ,gBAAkB,gBAE1B,aAAa,QAAQ,oBAAqB","file":"/npm/@cliqz/adblocker-electron@1.34.0/dist/commonjs/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@cliqz/adblocker-electron@1.34.0/dist/commonjs/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\n/*!\n * Copyright (c) 2017-present Ghostery GmbH. All rights reserved.\n *\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n    if (k2 === undefined) k2 = k;\n    var desc = Object.getOwnPropertyDescriptor(m, k);\n    if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n      desc = { enumerable: true, get: function() { return m[k]; } };\n    }\n    Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n    if (k2 === undefined) k2 = k;\n    o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n    Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n    o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n    if (mod && mod.__esModule) return mod;\n    var result = {};\n    if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n    __setModuleDefault(result, mod);\n    return result;\n};\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n    for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ElectronBlocker = exports.BlockingContext = void 0;\nexports.fromElectronDetails = fromElectronDetails;\nconst electron = __importStar(require(\"electron\"));\nconst tldts_experimental_1 = require(\"tldts-experimental\");\nconst adblocker_1 = require(\"@cliqz/adblocker\");\nconst preload_path_js_1 = require(\"./preload_path.js\");\nconst { ipcMain } = electron;\n// https://stackoverflow.com/questions/48854265/why-do-i-see-an-electron-security-warning-after-updating-my-electron-project-t\nprocess.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';\n/**\n * Create an instance of `Request` from `Electron.OnBeforeRequestDetails`.\n */\nfunction fromElectronDetails(details) {\n    const { id, url, resourceType, referrer, webContentsId } = details;\n    return adblocker_1.Request.fromRawDetails(webContentsId\n        ? {\n            _originalRequestDetails: details,\n            requestId: `${id}`,\n            sourceUrl: referrer,\n            tabId: webContentsId,\n            type: (resourceType || 'other'),\n            url,\n        }\n        : {\n            _originalRequestDetails: details,\n            requestId: `${id}`,\n            sourceUrl: referrer,\n            type: (resourceType || 'other'),\n            url,\n        });\n}\n/**\n * This abstraction takes care of blocking in one instance of `Electron.Session`.\n */\nclass BlockingContext {\n    constructor(session, blocker) {\n        this.session = session;\n        this.blocker = blocker;\n        this.onBeforeRequest = (details, callback) => blocker.onBeforeRequest(details, callback);\n        this.onGetCosmeticFiltersFirst = (event, url) => blocker.onGetCosmeticFiltersFirst(event, url);\n        this.onGetCosmeticFiltersUpdated = (event, url, msg) => blocker.onGetCosmeticFiltersUpdated(event, url, msg);\n        this.onHeadersReceived = (details, callback) => blocker.onHeadersReceived(details, callback);\n        this.onIsMutationObserverEnabled = (event) => blocker.onIsMutationObserverEnabled(event);\n    }\n    enable() {\n        if (this.blocker.config.loadCosmeticFilters === true) {\n            this.session.setPreloads(this.session.getPreloads().concat([preload_path_js_1.PRELOAD_PATH]));\n            ipcMain.on('get-cosmetic-filters-first', this.onGetCosmeticFiltersFirst);\n            ipcMain.on('get-cosmetic-filters', this.onGetCosmeticFiltersUpdated);\n            ipcMain.on('is-mutation-observer-enabled', this.onIsMutationObserverEnabled);\n        }\n        if (this.blocker.config.loadNetworkFilters === true) {\n            this.session.webRequest.onHeadersReceived({ urls: ['<all_urls>'] }, this.onHeadersReceived);\n            this.session.webRequest.onBeforeRequest({ urls: ['<all_urls>'] }, this.onBeforeRequest);\n        }\n    }\n    disable() {\n        if (this.blocker.config.loadNetworkFilters === true) {\n            // NOTE - there is currently no support in Electron for multiple\n            // webRequest listeners registered for the same event. This means that\n            // adblocker's listeners can be overriden by other ones in the same\n            // application (or that the adblocker can override another listener\n            // registered previously). Because of this, the only way to disable the\n            // adblocker is to remove all listeners for the events we are interested\n            // in. In the future, we should consider implementing a webRequest\n            // pipeline allowing to register multiple listeners for the same event.\n            this.session.webRequest.onHeadersReceived(null);\n            this.session.webRequest.onBeforeRequest(null);\n        }\n        if (this.blocker.config.loadCosmeticFilters === true) {\n            this.session.setPreloads(this.session.getPreloads().filter((p) => p !== preload_path_js_1.PRELOAD_PATH));\n            ipcMain.removeListener('get-cosmetic-filters', this.onGetCosmeticFiltersUpdated);\n        }\n    }\n}\nexports.BlockingContext = BlockingContext;\n/**\n * Wrap `FiltersEngine` into a Electron-friendly helper class. It exposes\n * methods to interface with Electron APIs needed to block ads.\n */\nclass ElectronBlocker extends adblocker_1.FiltersEngine {\n    constructor() {\n        super(...arguments);\n        this.contexts = new WeakMap();\n        // ----------------------------------------------------------------------- //\n        // ElectronBlocker-specific additions to FiltersEngine\n        // ----------------------------------------------------------------------- //\n        this.onIsMutationObserverEnabled = (event) => {\n            event.returnValue = this.config.enableMutationObserver;\n        };\n        this.onGetCosmeticFiltersFirst = (event, url) => {\n            // Extract hostname from sender's URL\n            const parsed = (0, tldts_experimental_1.parse)(url);\n            const hostname = parsed.hostname || '';\n            const domain = parsed.domain || '';\n            const { active, styles, scripts, extended } = this.getCosmeticsFilters({\n                domain,\n                hostname,\n                url,\n                // This needs to be done only once per frame\n                getBaseRules: true,\n                getInjectionRules: true,\n                getExtendedRules: true,\n                getRulesFromHostname: true,\n                getRulesFromDOM: false, // Only done on updates (see `onGetCosmeticFiltersUpdated`)\n                callerContext: {\n                    frameId: event.frameId,\n                    processId: event.processId,\n                },\n            });\n            if (active === false) {\n                event.returnValue = null;\n                return;\n            }\n            // Inject custom stylesheets\n            this.injectStyles(event.sender, styles);\n            event.sender.send('get-cosmetic-filters-response', {\n                active,\n                extended,\n                styles: '',\n            });\n            // to execute Inject scripts synchronously, simply return scripts to renderer.\n            event.returnValue = scripts;\n        };\n        this.onGetCosmeticFiltersUpdated = (event, url, msg) => {\n            // Extract hostname from sender's URL\n            const parsed = (0, tldts_experimental_1.parse)(url);\n            const hostname = parsed.hostname || '';\n            const domain = parsed.domain || '';\n            const { active, styles, extended } = this.getCosmeticsFilters({\n                domain,\n                hostname,\n                url,\n                classes: msg.classes,\n                hrefs: msg.hrefs,\n                ids: msg.ids,\n                // Only done on first load in the frame, disable for updates\n                getBaseRules: false,\n                getInjectionRules: false,\n                getExtendedRules: false,\n                getRulesFromHostname: false,\n                // This will be done every time we get information about DOM mutation\n                getRulesFromDOM: true,\n                callerContext: {\n                    frameId: event.frameId,\n                    processId: event.processId,\n                    lifecycle: msg.lifecycle,\n                },\n            });\n            if (active === false) {\n                return;\n            }\n            // Inject custom stylesheets\n            this.injectStyles(event.sender, styles);\n            // Inject scripts from content script\n            event.sender.send('get-cosmetic-filters-response', {\n                active,\n                extended,\n                styles: '',\n            });\n        };\n        this.onHeadersReceived = (details, callback) => {\n            const CSP_HEADER_NAME = 'content-security-policy';\n            const policies = [];\n            const responseHeaders = details.responseHeaders || {};\n            if (details.resourceType === 'mainFrame' || details.resourceType === 'subFrame') {\n                const rawCSP = this.getCSPDirectives(fromElectronDetails(details));\n                if (rawCSP !== undefined) {\n                    policies.push(...rawCSP.split(';').map((csp) => csp.trim()));\n                    // Collect existing CSP headers from response\n                    for (const [name, values] of Object.entries(responseHeaders)) {\n                        if (name.toLowerCase() === CSP_HEADER_NAME) {\n                            policies.push(...values);\n                            delete responseHeaders[name];\n                        }\n                    }\n                    responseHeaders[CSP_HEADER_NAME] = [policies.join(';')];\n                    callback({ responseHeaders });\n                    return;\n                }\n            }\n            callback({});\n        };\n        this.onBeforeRequest = (details, callback) => {\n            const request = fromElectronDetails(details);\n            if (this.config.guessRequestTypeFromUrl === true && request.type === 'other') {\n                request.guessTypeOfRequest();\n            }\n            if (request.isMainFrame()) {\n                callback({});\n                return;\n            }\n            const { redirect, match } = this.match(request);\n            if (redirect) {\n                callback({ redirectURL: redirect.dataUrl });\n            }\n            else if (match) {\n                callback({ cancel: true });\n            }\n            else {\n                callback({});\n            }\n        };\n    }\n    // ----------------------------------------------------------------------- //\n    // Helpers to enable and disable blocking for 'browser'\n    // ----------------------------------------------------------------------- //\n    enableBlockingInSession(session) {\n        let context = this.contexts.get(session);\n        if (context !== undefined) {\n            return context;\n        }\n        // Create new blocking context for `session`\n        context = new BlockingContext(session, this);\n        this.contexts.set(session, context);\n        context.enable();\n        return context;\n    }\n    disableBlockingInSession(session) {\n        const context = this.contexts.get(session);\n        if (context === undefined) {\n            throw new Error('Trying to disable blocking which was not enabled');\n        }\n        this.contexts.delete(session);\n        context.disable();\n    }\n    isBlockingEnabled(session) {\n        return this.contexts.has(session);\n    }\n    injectStyles(sender, styles) {\n        if (styles.length > 0) {\n            sender.insertCSS(styles, {\n                cssOrigin: 'user',\n            });\n        }\n    }\n}\nexports.ElectronBlocker = ElectronBlocker;\n// re-export @cliqz/adblocker symbols for convenience\n__exportStar(require(\"@cliqz/adblocker\"), exports);\n"]}