/** * Remove integrity checks from embedded CSS and JavaScript files * Belongs to LocalCDN. * * @author nobody42 * @since 2020-02-27 * * @license MPL 2.0 * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict'; /** * Manipulate DOM */ var manipulateDOM = {}; /** * Private Methods */ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) { // by Jaap (https://gitlab.com/Jaaap) let header = details.responseHeaders.find(h => h.name.toLowerCase() === 'content-type'); if (header && BrowserType.FIREFOX) { let mimeType, initiatorDomain, isWhitelisted; mimeType = header.value.replace(/;.*/, '').toLowerCase(); initiatorDomain = helpers.extractDomainFromUrl(details.url, true) || Address.EXAMPLE; isWhitelisted = stateManager._domainIsWhitelisted(initiatorDomain); if (!isWhitelisted && mimeType === 'text/html') { let asciiDecoder, decoder, encoder, charset, isFirstData, filter; asciiDecoder = new TextDecoder('ASCII'); encoder = new TextEncoder(); charset = /charset\s*=/.test(header.value) && header.value.replace(/^.*?charset\s*=\s*/, '').replace(/["']?/g, ''); // Check if charset is supported by TextDecoder() if(EncodingTypes[charset.toString().toLowerCase()] == undefined){ charset = false; } isFirstData = true; filter = browser.webRequest.filterResponseData(details.requestId); header.value = 'text/html; charset=UTF-8'; //Note that this will not work if the '