need to communicate with Extension - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: need to communicate with Extension (/showthread.php?tid=73332) Pages:
1
2
|
need to communicate with Extension - richb201 - 04-12-2019 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? RE: need to communicate with Extension - InsiteFX - 04-13-2019 This should explain it to you. Chrome - Message Passing RE: need to communicate with Extension - richb201 - 04-14-2019 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() RE: need to communicate with Extension - InsiteFX - 04-14-2019 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. RE: need to communicate with Extension - InsiteFX - 04-14-2019 Is this what your trying to do? Run chrome extension and submit data to PHP script on page load (automate the process) RE: need to communicate with Extension - richb201 - 04-14-2019 (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. RE: need to communicate with Extension - InsiteFX - 04-14-2019 You can use the Chrome developer tools to view what is happening F12. RE: need to communicate with Extension - richb201 - 04-15-2019 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? RE: need to communicate with Extension - InsiteFX - 04-16-2019 try calling it from your html view file. RE: need to communicate with Extension - richb201 - 04-16-2019 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> |