javascript - Chrome desktop notification for dynamic site update when chrome runs in background -
i've created bookmark extension community website, host posts, need have desktop notification of new posts in community site. chrome runs on background, no tabs opened, unless notified desktop notification.
idea send message background page content script regular interval , updates on post , display desktop notification, thereby user opens update on seeing notification.
query: how access dom of website (when chrome running in background), hiding extraction process user eye.
thanks !!
edit
var statone; var xhr = new xmlhttprequest(); xhr.open("get", "https://www.dsswym.3ds.com/", true); xhr.onreadystatechange = function() { if (xhr.readystate == 4 && xhr.status==200) { settimeout(function(){ //wait webpage loading statone = $('#widgetpanel-7qrsn8cawqkk0dp2_gqk').text(); console.log(statone); alert(statone); }, 10000); } } xhr.send();
i'm not able text values on above code, instead alert box empty. source site doesn't provide xml or json file, need extract first content or update on site.
you need use response xmlhttprequest
. doing xmlhttprequest
request doesn't load request resource page.
in jquery, can this:
$.get("https://www.dsswym.3ds.com/", function(data) { // load response text new page element var fakepage = document.createelement("html"); fakepage.innerhtml = data; // find desired element within new page element var statone = $(fakepage).find('#widgetpanel-7qrsn8cawqkk0dp2_gqk').text(); console.log(statone); } });
this stores result of ajax fetch innerhtml
of new <html>
element, cases text parsed new dom. use jquery's .find
method element need out of dom.
Comments
Post a Comment