Thanks for the code, but I am facing another problem with below code in background.js.
var ls = localStorage;
chrome.extension.onRequest.addListener(
function (req) {
var rtGroup = JSON.parse(ls.rtGroupInfo);
rtGroup.oWindows[parseInt(req.winId)].oTabs[parseInt(req.tabId)].scrRight = parseInt(req.scrollLeft);
rtGroup.oWindows[parseInt(req.winId)].oTabs[parseInt(req.tabId)].scrDown = parseInt(req.scrollTop);
ls.rtGroupInfo = JSON.stringify(rtGroup);
}
);
// Get Scroll Left and Scroll Top position
console.log(ls.rtGroupInfo);
if (ls.rtGroupInfo != undefined) {
var rtGroup = JSON.parse(ls.rtGroupInfo);
for (var i = 0; i < rtGroup.oWindows.length; i++) {
for (var j = 0; j < rtGroup.oWindows[i].oTabs.length; j++) {
chrome.tabs.executeScript(rtGroup.oWindows[i].oTabs[j].id, {"code": "chrome.extension.sendRequest({winId: " + i + ", tabId: " + j + ", scrollLeft: " + "document.body.scrollLeft" + ", scrollTop: " + "document.body.scrollTop})"});
}
}
}
In above code, when I put debug pointer on line "if (ls.rtGroupInfo != undefined)" ... I get proper value, otherwise it is "undefined". Any idea?
Thanks,
Hemang