I've been trying to write a chrome extension that tracks all of a users scrolling across their browser window and sends this data to chrome.storage.sync
I've been unsuccessful in seeing any data recorded in chrome.storage and am not sure if this because of the scroller.js script I have included below or if I have not directed to .storage correctly.
I haven't been able to find a solution from other answers posted here so any help would be greatly appreciated!
manifest.json
{
"manifest_version": 2,
"name": "Caressing the Silver Rectangle",
"description": "Measures Jesse Bowling's distance scrolled in pixels on Google Chrome",
"version": "1.0",
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"scroller.js"
],
"run_at": "document_start"
}
],
"background": [
{ "scripts": ["https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"]
}
],
"browser_action": {
"default_icon":"icon.png",
"default_title": "Caressing the Silver Rectangle",
"default_popup": "popup.html"
},
"permissions": [
"activeTab",
"<all_urls>",
"tabs",
"storage"
]
}
scroller.js
/*jslint devel: true */
var totalScroll;
var lastKnownScrollPos = 0;
window.addEventListener("scroll", function () {
"use strict";
console.log(lastKnownScrollPos);
totalScroll += Math.abs(window.scrollY - lastKnownScrollPos);
lastKnownScrollPos = window.scrollY;
chrome.storage.local.sync({ scroll: totalScroll });
});