Hello everyone,
I get content of a downloaded page in Chrome extension. Mostly content is retrieved wholly, but on some pages it returns 39 symbols. And on my observation it doesn't depend on the size of these pages. For instance, I get length of the page
https://clockify.me/ in the size of 30475, the page
https://clockify.me/time-management-techniques - 39.
manifest.json
{
"name": "Getting Started Example",
"description": "Build an Extension!",
"version": "1.0",
"manifest_version": 3,
"permissions": [
"storage",
"activeTab",
"scripting"
],
"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "images/icon-16.png",
"32": "images/icon-32.png",
"36": "images/icon-36.png"
}
},
"icons": {
"16": "images/icon-16.png",
"32": "images/icon-32.png",
"36": "images/icon-36.png"
}
}
popup.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="size"></div>
<script src="popup.js"></script>
</body>
</html>
popup.js
chrome.runtime.onMessage.addListener(function (request, sender) {
if (request.action == "getSource") {
document.getElementById('size').innerHTML = request.source.length;
}
});
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
chrome.scripting.executeScript({
target: { tabId: tabs[0].id, allFrames: true },
files: ['cscript.js']
});
});
cscript.js
var s = document.documentElement.outerHTML;
chrome.runtime.sendMessage({ action: "getSource", source: s });