Is there a way to access the HTML of an In App Browser (Themeable Browser) - html

I am using the ionic framework and would like to be able to read from the HTML from the current webpage and then send the selection back to my application.
I have the Theme-able Browser Plugin setup and can use it like any other web browser.
I have tried looking at ways to include my own script with the .executeScript() function but no luck.
I have also tried to read data from custom buttons that I have inserted into the tool/nav bar but that gives me the HTML of my application.
TL;DR: (Basically want access to the DOM of the current webpage and have the user use native selection to read the document.getSelection() and send that text back to my application.)
Any help would be highly appreciated.

After browsing the forums on Ionic I found the solution:
browser.executeScript({code:'window.getSelection().toString();'}).then((selection)=>{
packet.text = selection[0];});
This allows me to get the selection.

Related

Saving static HTML page generated with ReactJS

Background:
I need to allow users to create web pages for various products, with each page having a standard overall appearance. So basically, I will have a template, and based on the input data I need the HTML page to be generated for each product. The input data will be submitted via a web form, following which the data should be merged with the template to produce the output.
I initially considered using a pure templating approach such as Nunjucks, but moved to ReactJS as I have prior experience with the latter.
Problem:
Once I display the output page (by adding the user input to the template file with placeholders), I am getting the desired output page displayed in the browser. But how can I now obtain the HTML code for this specific page?
When I tried to view the source code of the page, I see the contents of 'public/index.html' stating:
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expectedly, the same happens when I try to save (Save As...) the html page via the browser. I understand why the above happens.
But I cannot find a solution to my requirement. Can anyone tell me how I can download/save the static source code for the output page displayed on the browser.
I have read possible solutions such as installing 'React/Redux Development Extension' etc... but these would not work as a solution for external users (who cannot be expected to install these extensions to use my tool). I need a way to do this on production environment.
p.s. Having read the "background" info of my task, do let me know if you can think of any better ways of approaching this.
Edit note:
My app is currently actually just a single page, that accepts user data via a form and displays the output (in a full screen dialog). I don't wish to have these output pages 'published' on the website, and these are simply to be saved/downloaded for internal use. So simply being able to get the "source code" for the dislayed view/page on the browser and saving this to a file would solve my problem. But I am not sure if there is a way to do this?
Its recommended that you use a well-known site generator such as Gatsby or Next for your static sites since "npx create-react-app my-app" is for single page apps.
(ref: https://reactjs.org/docs/create-a-new-react-app.html#recommended-toolchains)
If I'm understanding correctly, you need to generate a new page link for each user. Each of your users will have their own link (http/https) to share with their users.
For example, a scheduling tool will need each user to create their own "booking page", which is a generated link (could be on your domain --> www.yourdomain.com/bookinguser1).
You'll need user profiles to store each user's custom page, a database, and such. If you're not comfortable, I'll use something like an e-commerce tool that will do it for you.
You can turn on the debugger (f12) and go to "Elements"
Then right-click on the HTML tag and press edit as HTML
And then copy everything (ctrl + a)

Extract and Display information using webview and WxPython

I am creating a application where the UI is been formed using WxPython. I am using a Panel with a HTML window.
In this HTML page which is displayed, I would like to extract information, for example the text of a textBox, which radio button is selected, a click of a button etc, and at the same time show some information to the user, like when a process was been completed and its result or similar information.
I am not finding a good way of doing that, as long I could understand, I will need to use Javascript or something to interact with the page in some way. But I could not find how to send and receive information to the page, and if the wx.html.HtmlWindow supports Javascript.
What would be the best way of doing that?
You could communicate through a socket. Create a local socket server on the python side, and then use javascript to connect to that socket. There are plenty examples of this around the web. See the docs for python Socket Server: https://docs.python.org/2/library/socketserver.html
It doesn't look like the wx.html module supports javascript or css:
This module contains a widget class and supporting classes for a generic HTML renderer. It supports only a subset of the HTML standards, and no Javascript or CSS, but it is relatively lightweight and has no platform dependencies. It is suitable for displaying simple HTML documents, such as the application’s documentation or built-in help pages.
It does look like you can handle the EVT_HTML_LINK_CLICKED event to tell when a user clicks a link, but I'm not sure how you would get the input from html form elements like textboxes, radio buttons, etc.
Your best bet may be to create a web app using a microframework like Flask and serve the app locally.

What could be different ways of creating a user interface for a chrome extension?

I am trying to learn what could be the best ways of developing user interface for chrome extension for my application. The 2 approaches that I have come across are i)Using a browser action with default_popup html page or ii) Injecting some component into the page that is loaded in the tab. First approach is pretty straightforward but has some restricted use (like it is destroyed on tab/window switch which is useful in the context of my application). Coming to the second approach, it seems it requires every component which can be injected to be listed under web_accessible_resources. As the extension UI gets complex, this list is bound to increase. But surprisingly, Pocket extension's manifest does not seem to list any js files or html files though it does not use a popup page too. How does it work? Is there any other way of creating the user interface too?
Have you checked on the documentation regarding chrome.windows API? This API will allow you to create new windows and tabs in the browser, so you can create the html content from your extension. All you'll need is declaring the pertinent permissions on the manifest file. You can read more information here: https://developer.chrome.com/extensions/windows

How to Access DOM of new web page opened in Chrome

i am writing a NPAPI plugin for that i am using NPSIMPLE sample code from google chrome. i have to get the DOM of web page opened in the chrome browser. My plugin solution also includes background.html file. which when i open in chrome browser calls a method in NPAPI plugin. so my plugin can get the URL of this file. now i want to read the DOM structure of this File.
i have few questions:
when a new page is opened in browser by user how i have to embed my plugin to that page and get the DOM of that page?
whenever a new tab is opened how can i get the notification in My plugin?
How to get the DOM mutation notification to my plugin?
Does NPAPI provides API to get the DOM mutation notification or Content Script is the only option? if content script is the only option then how to establish communication between plugin and content_script?
i am trying to get this answers as well. any help greatly appreciated...
thanks in advance...
1) The only way you could do this automatically would be to put the plugin inside an extension and do it with the extension.
2) You can't, since plugins don't know anything outside of the page they are in. You might be able to jury-rig something using an extension, I suppose, but I'm not sure if that's possible or not.
3 and 4) Your best bet is probably to figure out how to get these notifications with javascript and inject javascript that will call back into your plugin.
Sounds like one of your main sticking points is that you aren't clear on what a plugin can do; you may want to read up a bit.

Getting iframe URL using Scala/Lift

all. I am working on a Scala/Lift web application that uses an iframe to display content from another web application hosted on the same domain. Is there a way to access the URL of the child frame's currently-displayed page? The suggested solutions found for the general problem typically use Javascript, but I would to like accomplish this with Scala if possible.
Thanks!
I don't believe this would be possible, presuming you are trying to read the current page that it is on rather than the page that is sent by default.
If you are trying to read the current page it is on then that would necessitate interaction between the server and the client, meaning you would have to use some javascript. If you are trying to find the page it was on originally then that should have been set earlier in your program so you will be able to just store that value in a variable and access it later.
If you clarified which you were trying to do you might get a more complete answer.