need to communicate with Extension |
I have a Chrome Extension that is installed in the same browser that is hosting my CI based app. I need to communicate from the web app to the Extension. I was told that I could do this by running this in the web app:
Code: chrome.runtime.sendMessage(editorExtensionId, {openUrlInEditor: url}, The question is "how do I run the above code from my CI based php app"? Is that javascript that I can run when my app starts up? Since the server is generating HTML pages, how do I get this working? I do need to see the result of this call since I will "grey out" certain functions in my web app if the Extension is not found. Any clues?
proof that an old dog can learn new tricks
This should explain it to you.
Chrome - Message Passing What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Yes, Insite, that is what I am following.
Sending messages from web pages Similar to cross-extension messaging, your app or extension can receive and respond to messages from regular web pages. a few lines down they have this example: // The ID of the extension we want to talk to. var editorExtensionId = "abcdefghijklmnoabcdefhijklmnoabc"; // Make a simple request: chrome.runtime.sendMessage(editorExtensionId, {openUrlInEditor: url}, function(response) { if (!response.success) handleError(url); }); I thought maybe I could wrap this in javascript and drop it into the init function in my Controller: PHP Code: private function _init()
proof that an old dog can learn new tricks
To access the messaging you would need to do it using jQuery then do a post or get to
the controller to do what you need. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Is this what your trying to do?
Run chrome extension and submit data to PHP script on page load (automate the process) What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(04-14-2019, 08:28 AM)InsiteFX Wrote: Is this what your trying to do? Yes exactly. I created the .js file and am calling it with load_js(). In the file called by load js it doesn't seem to fire. I have tried both (document).load() and also (window).load(). Neither seems to fire. And how do I get a return code from the load_js? I need the web page to know if my extension is loaded and running. I could probably load a global return code just on this users pc?Could it be that my xdebug just can't debug js embedded in an html? I have the Chrome debugger on the extension, but it is not firing. I will read your quote now.
proof that an old dog can learn new tricks
You can use the Chrome developer tools to view what is happening F12.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I changed the .js function. Now it is this:
Code: $(register_extension( I tried calling this by using register_extension() in my directly in my controller. I am getting this error Fatal error: Call to undefined function register_extension() in /var/www/html/sub_crud/application/controllers/Configure.php on line 60 I guess I can't call a js function even in a .js file? How should I handle this?
proof that an old dog can learn new tricks
try calling it from your html view file.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I tried both calling it from the html section and also the php section of the view file. Or should I be loading is with load->view()?
Code: <!DOCTYPE html>
proof that an old dog can learn new tricks
|
Welcome Guest, Not a member yet? Register Sign In |