Launch a selenium webdriver from within a browser extension? - javascript

In a nutshell, I want to build a chrome extension that collects all data properties of an ad listing (e.g. title, description, photos etc.) that's open in one tab, then maps these to fields on a different site (to be opened in a headless browser) and submit the newly created listing. Basically, automate listing submission to multiple sites.
Now, opening the source url and crawling for the data won't be an issue. But how do I (headlessly in the background) populate and submit the target form, with the photo upload being implemented in js being the trickiest part.
So how do I go about this? Would it be possible to bundle and launch a selenium webdriver from within the background script at all or I should look into a completely different direction?
Many thanks for any tips you might have!

Related

Use Cmd+P / save as PDF to save many page of website as PDFs - using one of R, JavaScript

Being able to quickly and easily visit many pages of our website, and save those pages as local PDFs, is essential for a feature we're building into our app. This question on the topic was marked as duplicate, and so I wanted to adjust the question:
We have a website that:
has a login to get through
has 100s of pages we'd like to visit and save as PDFs
Rather than using some complex JS PDF library for this, we're leveraging chrome's built in Cmd+P to launch print panel and then Destination: Save as PDF to save the entire webpage as a single PDF file. Our website is built so that pages save neatly to PDF using the browsers built-in save-to-pdf functionality.
What is the best way to automate this process over 100s of URLs? We can very easily, in R or JS, create an array of the 100s of different page URLs that need to be visited. Is RSelenium a smart approach for this, like how it's used in the hyperlink? We are currently stuck with RSelenium as the linked answer in that question is not working for us. We are able to launch the print panel, however we cannot use RSelenium to click the Destination toggle nor the save button in the print panel.
Perhaps there is an easier way to do this using JavaScript?
Edit: I've given Mac's Automator a try, and have figured out how to open multiple pages at once. However it's not clear how to then automatically save the pages to PDF. It also doesn't seem sound to have 100s of tabs all open at the same time in browser.

Can I manipulate/manage some website through Chrome app?

I need to simulate the user's work - click buttons, enter data in the field and so on. Is this can be done only through using executeScript or I can receive DOM of and manipulate with it? Or maybe I can work with the tab in the browser separately or exist some other way to do what I need?
I do not believe that you can do this with a Chrome App, but you can do this using a Chrome Extension. Extensions can have full access to a tab's DOM and you can manipulate the DOM as needed. (e.g. fill in form fields, click buttons, etc...).
From: https://developer.chrome.com/extensions/overview
Extensions can interact with web pages or servers using content scripts or cross-origin XMLHttpRequests.
This is how extensions like LastPass are able to fill in the username and password field on any web page you visit.

Web ERP System. Print system invoice without editing, downloading

My web system has print invoice function. I need to prevent the user from:
Editing the invoice in a web browser (F12)
Saving the invoice to local
Please give me some solutions.
My invoice is render in html.
Editing the invoice in a web browser (F12)
Using "browser hacks" to disable a web browser's developer tools, to prevent users from editing the invoice for their own purpose is not a sound strategy. The code that would otherwise block or limit the use of the developer tools keeps changing as browsers are updated.
But, if your still interested in pursuing this path, have a look at this question: How does Facebook disable the browser's integrated Developer Tools?.
Saving the invoice to local
Acknowledging that everything viewed on browser, had to be downloaded in the first place to be viewed.
You can't really stop users from saving a copy of the invoice, you can however, make it harder for regular users to save a copy to their documents folder or other folder they choose for that matter.
Anyway, assuming you can make the invoices available in PDF format, have you considered using the embeddable Google document viewer?
It allows you to view a number of documents within the confines of a web browser, sorry I cannot find the documentation online, but its usage is pretty straightforward.
<iframe src="//docs.google.com/gview?url=http://example.com/invoice/123.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>
Fiddle
Replace http://example.com/invoice/123.pdf with the URL to the particular invoice.
This would allow users to view the invoice, yet prevent normal users from editing and/or saving it for later use.
However, it wouldn't prevent a user with the same knowledge required to make of use of the developer tools, from viewing the source and grabbing the URL for the invoice from the source of that iframe.

Save email to outlook folder using ActiveXObject or Office Javascript API?

In outlook, there is a feature “Home page address” of folder through which we can view web site within the outlook. If we set http://app.abctest.com in the Home page address of a folder, then when we click this folder in the outlook, it will display that page.
I have a very specific requirement for enabling end user to browse a web site (in my case, it basically lists some archived emails) within from the Outlook. This can be easily done by setting the “Home page address” in the properties windows of any Folder of Outlook.
The user will see the page within outlook. He can search the old archived emails in the page. Then, the users should be able to download that email and save it to a folder in outlook. End users are basically searching the emails within outlook and downloading them from the server directly to their outlook folder. When user click the download\save link or button, then the outlook’s “Select Folder” dialog should appear where user can select the destination folder. When user click “OK” button, that email should be save to the selected folder in the outlook.
Currently, I have very few solutions but not sure if they can achieve the goal.
Solution 1: ActiveXObject
I tried to use Outlook ActiveXObject in javascript (used the following code in my test page) but I got the following Script error Popup message.
“Automation server cannot create the object”.
Javascript code:
var objO = new ActiveXObject('Outlook.Application');
Solution 2: Javascript API for Office
I have started to read the MSDN documentation https://msdn.microsoft.com/en-us/library/office/fp142185.aspx but have not got any sample code.
Could someone please sheds some light on it? Or what would be the best solution for this? Or any alternative solution.
Prakash,
Only one instance of Outlook can be run at the same time. Try to use the GetObject function instead to get the running Outlook instance instead. See How to programmatically create an Outlook home folder page in the Outlook Today style for more information. However, home page scripting is limited and secured to prevent malicious software. I'd suggest developing an add-in which can add a custom form instead.
The second solution listed above is for Mail Apps. See How to: Create your first mail app for Outlook by using Visual Studio for more information.
When your script runs inside a folder home page, window.external.OutlookApplication will point to an instance off the Outlook.Application object - your should be able to use it without creating a new object.

How can I prevent saving/downloading web page?

I was wondering if there was a way to prevent a user from saving/downloading a web page? Specifically, I mean not letting them have access to the data displayed through my web application on their own machine?
I've heard that this is not possible since the browser must have access to the source code/data, but at the same time, I've noticed that if I to my gmail account, open an email, save the page, but when I try to open that page on my computer, it doesn't work. Furthermore, if I click "view source", I can see that even the source does not display the entire email message, even though the email is opened in my browser.
How it's possible for gmail to prevent me from seeing that email data?
Thats what called rendering pages using dynamic data without refreshing page (AJAX). The entire page source code is not downloaded in one go and components within the page request data asynchronously to display content. Try googling it and you will find more information.
In View source you can only see the HTML, CSS, JavaScript codes. No one can copy any dynamic code (PHP) from view source.
You can't stop anyone to see your html,css code in browser, as we are having view source option.
Maximum what you can do is disable right click on your page. Thant can be done through JavaScript.

Categories

Resources