I'm bulilding a chrome extension.
In this part of code I try to find paragraphs in loaded page, for each paragraph in divs with id load and detail, I search if value of findCheckedFact
is inside that paragraph if yes I cut I want to put that text inside a span with a class red.
findCheckedFact
is a string. Here in +'console.log("Print:", str_p, " Fact:", findCheckedFact);'
the text inside paragraph is defined but the parameter findCheckedFact is not defined, so I cant pass it?
This function I tried calling findTextInsideParagraphs("test");
.
function findTextInsideParagraphs(findCheckedFact){
chrome.tabs.executeScript({file: "js/jquery-1.12.0.min.js"}, function() {
chrome.tabs.executeScript({"code":
'(function(findCheckedFact){'
+'$("#lead, #detail").find("p").each(function() {'
+'var str_p = $(this).text();'
+'console.log("Print:", str_p, " Fact:", findCheckedFact);'
+'if (str_p.indexOf( findCheckedFact) >= 0) {'
+'console.log("Yes kest");'
+'$(this).html($(this).html().replace(findCheckedFact, "<span class=\'red\'> $& </span>"));'
+'}'
+'});'
+'}(' + JSON.stringify("Fact: " , findCheckedFact) + '));'
});
});
}
This function I tried calling findTextInsideParagraphs("test"); Inside manifest.json I did add everythin possible to make it work:
"content_scripts": [
{
"matches": [
"<all_urls>",
"http://*/*",
"https://*/*"
],
"css": [
"custom-css.css"
],
"js": [
"js/jquery-1.12.0.min.js"
],
"run_at": "document_start"
}],
"background": {
"persistent": false,
"scripts": [
"js/jquery-1.12.0.min.js",
"background.js",
"popup.js",
"blic-fact-checker.js"
],
"css":["custom-css.css"]
},
"permissions": [
"background",
"notifications",
"contextMenus",
"storage",
"tabs",
"activeTab",
"http://localhost:5000/*",
"chrome-extension://genmdmadineagnhncmefadakpchajbkj/blic-fact-checker.js",
"chrome-devtools://devtools/bundled/inspector.html?&remoteBase=https://chrome-devtools-frontend.appspot.com/serve_file/@202161/&dockSide=undocked",
"http://*/*",
"https://*/*",
"<all_urls>"
],
Can somebody help me with this,really I can't find what's going on ?