Run javascript on an externally loaded page - possible?

I don’t think this is possible but always worth asking…

I want to execute some javascript on a page which is externally loaded from a workflow.

I can manually go to the page, hit F12 and then copy/paste the javascript into the console and it works fine. But I want to be able to do this from within a workflow.

Any way to do this from within bubble?

Thanks,

Not sure if this is what you mean, but there is a free plugin called Toolbox. It has an action called Run Javascript. You can run javascript code in it.

Hey,

Yeah I know about the Toolbox plugin, my boggle is that I want the javascript to run in an externally opened window, and Im not sure if that’s possible, and if it is, how to do so.

Thanks,

Is it another Bubble page or a link to a different site completely?

If you use the javascript to open the new window then you can run javascript in it. Here is the solution.

Its a different site altogether.

Funnily enough I found my way to that same page you linked.

However I think I’ve hit a stumbling block when it comes to security, something about cross-origins. The jist I’m getting is that basic browser security does not allow for scripts to be run from different windows by default, which I can kind of understand since you could have some malicious code contained within a link.

So that’s a bummer.

Hey Phillip,

This is interesting. This is actually something you can do with a service I made called Deskifier.

This would allow you to create a new window that loads the external site and then you can programmatically inject your own JS into this new window.

Since this is a desktop app (basically a custom web browser) security restrictions like the one you mentioned don’t occur.

1 Like

Hi,

This looks interesting. I’ve had a quick go with it, when I say for instance set a workflow that runs javascript to open a new window i.e window.open(“www.example.com”), then it still opens in my native browser, and not within the app as I assumed would happen.

Or is the idea to have a iframe within the app to load up the site and then run javascript within the iframe?

Thanks.

This is actually the intended behavior for window.open()

For creating new windows, this is done with the plugin Deskifier Link Plugin | Bubble

Running this action creates a window

We can add another event for when the new window is finished loading, and inside this WF we can run our action for running JS on that new window.

The window ID is set to “Relevant Workflow Window’s Window ID” - This is the Window ID of the new window that just finished loading.

Additionally, you can send messages back to the main window from that new window by using
window.deskifier.ipcRenderer('sendMessageFromWindow', 'put data here')

This JS will fire this event back in your main window

2 Likes

Wow, fantastic what you have put together here.

Unfortunately I’ve hit another pothole, the site I need to navigate to won’t load on the apps internal browser for some reason, which is a real shame as it was shaping up to do exactly what I needed it to.

Added to the bookmarks for future reference nonetheless!

Thanks.

Hmmm, that is odd. Is it just displaying a white screen?

If you are using the launch new window action, make sure you have https:// in front of the URL you are trying to open.

If that doesn’t work, I’m happy to help investigate the issue.

Will DM you thanks.

1 Like