I need my content script to run with privileges.
For my script to perform a privileged action, it needs to send a "message" to my background page,(background.html), so the background pages peforms it for it.
Here is my current content script:
function checkReq(){
var list = document.getElementById("gkpluginsExtListReq");
if(list===null){
return;
}
list.title = "ready";
if(list.childNodes.length>0){
var curReq = list.firstChild;
if(typeof curReq.innerHTML=="undefined"){
list.removeChild(curReq);
return;
}
var obj = JSON.parse(atob(curReq.innerHTML));
obj.onload = obj.onerror = obj.onabor = function(response){
var txtout = document.createElement("textarea");
txtout.id = obj.extreqid;
txtout.style.display = "none";
var Hfres = response.status+" "+response.statusText+"\r\n"+response.responseHeaders;
if(response.finalUrl){
Hfres += "FinalLocation: "+response.finalUrl+"\r\n";
}
if(obj.returndtaescape){
txtout.value = escape(Hfres+"\r\n"+response.responseText);
}else if(obj.returndtab64){
txtout.value = btoa(Hfres+"\r\n"+response.responseText);
}else{
txtout.value = Hfres+"\r\n"+response.responseText;
}
document.body.appendChild(txtout);
};
GM_xmlhttpRequest(obj);
list.removeChild(curReq);
}
}
setInterval(checkReq,100);
My background.html page is empty, because i until now, i had no luck to let it "comunicate" with my content script. I appreciate any help.
P.S: The Message Passing page from google chrome developer section didn't really help me out.
Forgot to mention, the script needs GM_xmlhttpRequest granted.// @grant GM_xmlhttpRequest
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/26c4e729-3e8d-4ea9-8de8-8bc3cec0a79a%40chromium.org.
Have you debugged your content script? Does it actually send a network request?Has the load event fired for the request?Also, onabor should probably be onabort.Wait, where is the code that sends a message to the background page?
☆PhistucK
On Sun, Aug 21, 2016 at 5:25 PM, Jeremiah Heisenberg <h41...@gmail.com> wrote:
Forgot to mention, the script needs GM_xmlhttpRequest granted.// @grant GM_xmlhttpRequest
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
Hey, first sorry, this is my first chrome extension.It does it work for other xhr work, but when it comes to set the origin header and such it gives me this kind of error:I've read about one hundred or more posts on stackoverflow, and then i found out that i had to make the html page to do that kind of work instead of the script?The javascript is also just another "worker" for another script that is @my website.When i install my script via tamermonkey or greasemonkey, it works completly fine.
Am Sonntag, 21. August 2016 17:41:27 UTC+2 schrieb PhistucK:
Have you debugged your content script? Does it actually send a network request?Has the load event fired for the request?Also, onabor should probably be onabort.Wait, where is the code that sends a message to the background page?
☆PhistucK
On Sun, Aug 21, 2016 at 5:25 PM, Jeremiah Heisenberg <h41...@gmail.com> wrote:
Forgot to mention, the script needs GM_xmlhttpRequest granted.// @grant GM_xmlhttpRequest
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/26c4e729-3e8d-4ea9-8de8-8bc3cec0a79a%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/0a7028ba-2014-468a-893b-100270454fe7%40chromium.org.
While they are errors, they are not exceptions (so you code keeps running).You have not answered my final (and most important, I guess) question - where in the code are you sending a message to your background page?You have not answered most of my questions, really. I am not entirely sure I even understand what it is that you are asking.
☆PhistucK
On Sun, Aug 21, 2016 at 10:04 PM, Jeremiah Heisenberg <h41...@gmail.com> wrote:
Hey, first sorry, this is my first chrome extension.It does it work for other xhr work, but when it comes to set the origin header and such it gives me this kind of error:I've read about one hundred or more posts on stackoverflow, and then i found out that i had to make the html page to do that kind of work instead of the script?The javascript is also just another "worker" for another script that is @my website.When i install my script via tamermonkey or greasemonkey, it works completly fine.
Am Sonntag, 21. August 2016 17:41:27 UTC+2 schrieb PhistucK:
Have you debugged your content script? Does it actually send a network request?Has the load event fired for the request?Also, onabor should probably be onabort.Wait, where is the code that sends a message to the background page?
☆PhistucK
On Sun, Aug 21, 2016 at 5:25 PM, Jeremiah Heisenberg <h41...@gmail.com> wrote:
Forgot to mention, the script needs GM_xmlhttpRequest granted.// @grant GM_xmlhttpRequest
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/26c4e729-3e8d-4ea9-8de8-8bc3cec0a79a%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
That's the problem, i don't know how to "convert" the script, to make it "communicate" with the background.html page.
Am Sonntag, 21. August 2016 22:44:11 UTC+2 schrieb PhistucK:
While they are errors, they are not exceptions (so you code keeps running).You have not answered my final (and most important, I guess) question - where in the code are you sending a message to your background page?You have not answered most of my questions, really. I am not entirely sure I even understand what it is that you are asking.
☆PhistucK
On Sun, Aug 21, 2016 at 10:04 PM, Jeremiah Heisenberg <h41...@gmail.com> wrote:
Hey, first sorry, this is my first chrome extension.It does it work for other xhr work, but when it comes to set the origin header and such it gives me this kind of error:I've read about one hundred or more posts on stackoverflow, and then i found out that i had to make the html page to do that kind of work instead of the script?The javascript is also just another "worker" for another script that is @my website.When i install my script via tamermonkey or greasemonkey, it works completly fine.
Am Sonntag, 21. August 2016 17:41:27 UTC+2 schrieb PhistucK:
Have you debugged your content script? Does it actually send a network request?Has the load event fired for the request?Also, onabor should probably be onabort.Wait, where is the code that sends a message to the background page?
☆PhistucK
On Sun, Aug 21, 2016 at 5:25 PM, Jeremiah Heisenberg <h41...@gmail.com> wrote:
Forgot to mention, the script needs GM_xmlhttpRequest granted.// @grant GM_xmlhttpRequest
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/26c4e729-3e8d-4ea9-8de8-8bc3cec0a79a%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/0a7028ba-2014-468a-893b-100270454fe7%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/2ebe3d93-0985-4e56-a87e-2866144a80cd%40chromium.org.
☆PhistucK
☆PhistucK
☆PhistucK
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/26c4e729-3e8d-4ea9-8de8-8bc3cec0a79a%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/0a7028ba-2014-468a-893b-100270454fe7%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
☆PhistucK
☆PhistucK
☆PhistucK
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/26c4e729-3e8d-4ea9-8de8-8bc3cec0a79a%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/0a7028ba-2014-468a-893b-100270454fe7%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/2ebe3d93-0985-4e56-a87e-2866144a80cd%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/9fb24dd5-9810-45d7-ac43-3e6e29598539%40chromium.org.
chrome.runtime.sendMessage(.......
Mean while your backgroud.js is waiting
Background script with listener.
chrome.runtime.onMessage.addListener(function....
do stuff in protected background....
sendResponse( {results of stuff for your content script.} )