• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
need to communicate with Extension

Here is how they do it using jQuery and a background js file.

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

(04-15-2019, 05:21 AM)richb201 Wrote: I changed the .js function. Now it is this:
   var editorExtensionId = "mebiphcpglaighebopfapfoiimgnnbpf";

   // Make a simple request:
   chrome.runtime.sendMessage(editorExtensionId, "register_extension",
       function(response) {
           if (!response.success)


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?
Similar to cross-extension messaging, your app or extension can receive and respond to messages from regular web pages. 

(04-14-2019, 10:06 AM)richb201 Wrote:
(04-14-2019, 08:28 AM)InsiteFX Wrote: Is this what your trying to do?

Run chrome extension and submit data to PHP script on page load (automate the process)

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() -->Audacity Find My iPhone Origin. 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.

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:

Well, with your guys help I managed to get the javascript running in a view. I am just having a small issue. I need to pass some data from my controller to the view.  I am using this:
       $data = array(
           'command' => "snapshot_mode",
           'userid' => "email",
           'campaign' => "campaign",
           'param_1' => "My Title"

       $this->load->view("javascript_funcs_extensionloaded", $data, TRUE);

And here is the view:

  $(document).ready( function(data) {
       var editorExtensionId = "lamacgnkfoiknjpleghfknfigbmhdaei";
       // unload when done
           chrome.runtime.sendMessage(editorExtensionId, "snapshot_mode_unload")
       chrome.runtime.sendMessage(editorExtensionId, jsonData);

This is not sending the jsonData to the extension. However, if I hard code in 

chrome.runtime.sendMessage(editorExtensionId, "snapshot_mode2");

that seems to work fine. So I think that the $data in php is not being passed to the data variable in the view. How to fix this?
proof that an old dog can learn new tricks

I was informed by phpStorm support that I cannot debug a php file as javascript. So I had application/views/javascript_funcs_extensionloaded.php that had my javsascript file. I was able to run the javascript but unable to debug it. So I changed it to application/views/javascript_funcs_extensionloaded.js. Now I can't run javascript at all.
proof that an old dog can learn new tricks

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.