need to communicate with Extension |
Here is how they do it using jQuery and a background js file.
CREATING A CHROME EXTENSION THAT USES JQUERY TO MANIPULATE THE DOM OF A PAGE 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: (04-14-2019, 10:06 AM)richb201 Wrote:(04-14-2019, 08:28 AM)InsiteFX Wrote: Is this what your trying to do? 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 $(window).on('beforeunload',(function(){ chrome.runtime.sendMessage(editorExtensionId, "snapshot_mode_unload") })) jsonData=JSON.stringify(data) 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
|
Welcome Guest, Not a member yet? Register Sign In |