0

I built a chrome extension to extract data from a medical site. It works fine with manifest version 2. But when I tried to deploy on chrome store, it said that I need to upgrade to manifest version 3. When I was migrating from version 2 to manifest version 3, it started giving many errors like

Failed to load extension or

Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-Wq/CW2mxkri68TjkuaA0+LnU0capVpyiEuSA5NOVNfU='), or a nonce ('nonce-...') is required to enable inline execution.

Also the official chrome extension website says manifest version 3 doesnt support crawling (dom manipulation)

https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/

Following is how I am using DOM data:

function DOMtoString(document_root) {
var html = "",
    node = document_root.firstChild;
while (node) {
    switch (node.nodeType) {
        case Node.ELEMENT_NODE:
            html += node.outerHTML;
            break;
        case Node.TEXT_NODE:
            html += node.nodeValue;
            break;
        case Node.CDATA_SECTION_NODE:
            html += "<![CDATA[" + node.nodeValue + "]]>";
            break;
        case Node.COMMENT_NODE:
            html += "<!--" + node.nodeValue + "-->";
            break;
        case Node.DOCUMENT_TYPE_NODE: // (X)HTML documents are identified by public identifiers
            html += "<!DOCTYPE " + node.name + (node.publicId ? ' PUBLIC "' + node.publicId + '"' : "") +
                (!node.publicId && node.systemId ? " SYSTEM" : "") + (node.systemId ? ' "' + node.systemId + '"' : "") + ">\t";
            break;
    }
    node = node.nextSibling;
}
var data = "";
html = html.trim();
html = html.replace(/\n/g, "");
html.replace(/&amp;/g, "&");

var apointmentGender;
var values = document.getElementsByClassName("modal fade orangetheme ng-scope in")[0];
if (values == undefined) {
    // 
    var account = document.getElementsByClassName("ml5 fs11 patient-identifier-span");

Here is the manifest file:

{
"name": "eCares",
"version": "1.0",
"manifest_version": 3,
"description": "Extract all data for eCares",
   "browser_action": {
    "default_icon": "images/logo/loginLogo_DarkBlue.png",
    "default_popup": "html/login.html"
},
"permissions": ["scripting"],
"host_permissions": ["<all_urls>"],
"background": {"service_worker": "scripts/custom/home.js"}

}

It would be great if someone can provide a workaround for this issue. I wonder what will happen to all the chrome extensions which run only on crawling or dom manipulatiton.

Shalin Jirawla
  • 489
  • 1
  • 5
  • 24

0 Answers0