class MessagingService { async GetHyperlinkNodes(sender, callback) { const a = this; const nodes = await document.body.getElementsByTagName("a"); let result = []; for (let i=0; i JSON.stringify(item) === JSON.stringify(result[i])).length; // } await callback(result); } async GetImageNodes(sender, callback) { const a = this; const nodes = await document.body.getElementsByTagName("img"); let result = []; for (let i=0; i": ">", '"': """, "'": "'", }; let result = (htmlContent ?? "").replace("\r", "").replace("\n", "\\n").replace("\t", "\\t"); result = result.replace(/[&<>"']/g, (char) => map[char]); return result; } } const messageService = new MessagingService(); chrome.runtime.onMessage.addListener(async function(request, sender, callback) { if (typeof(messageService[request.event]) == "undefined") { return; } await messageService[request.event](sender, callback); }); // var optHideWatchedVideos = new Promise(function(resolve) { // chrome.storage.local.get(['switch1'], function(result) { // resolve(result.switch1); // }); // });