Control Google Docs embedded viewer with JavaScript - google-docs

I need to control the embedded Google Docs viewer in my site. More specifically I need to be able to enable/disable the controls for Google Slides view and to be able to start/stop the presentation with JavaScript.
I was not able to find any JavaScript API for that, nor I have been able to add my host so my JavaScript to be able to communicate with the iframe content.
Anyone did something like this?

Google Docs doesn't work like that at all. Here are the steps you will need to take.
1: Create Presentation on Google Slides.
1a: https://docs.google.com/presentation/u/0/
2: Create any scripts you want applied in the script editor.
2a: https://developers.google.com/apps-script/guides/slides/
3: Publish Presentation.
3a: File>Publish to Web>Embed
4: Embed Presentation.
5: Create HTML Function call
6: Create Listener w/ Google Docs (Not on your site.)
If you want your site to be able to access and run scripts from google (Aka, disable controls.) Refer to this link below, it will show you how you can use HTML to request that a script is run from google docs. Keep in mind there is a limitation to daily function calls for free accounts w/ google. I believe it's 5500 calls per day max.
HTML Function Calls: https://developers.google.com/apps-script/guides/html/communication
You also mentioned iFrame, you can find information about that located here.
iFrame Sandboxing: https://developers.google.com/apps-script/migration/iframe

Related

Is there a way to click through GDPR privacy policies on webpages when web scraping in Python?

I am trying to scrape the the article text from articles like the following:
http://fortune.com/2017/05/05/chemchina-syngenta-deal-acquisition/
However, some websites, such as Fortune, will present a screen on your first visit on which you must consent to them using your data in certain ways.
I need my webscraping tool to move through this page and access and download the article html.
If you're required to perform actions on the page, you should look into using Selenium (https://selenium-python.readthedocs.io/).
Selenium is a webdriver which is exactly what it sounds like. It allows you to open a headless browser session which you drive via python code. You'll be able to parse through the HTML of the GDPR page, find the specific button/link/whatever you need to continue, send a keypress, then parse the following page to get the article text.
A webdriver is a great tool to use when you need to interact with a webserver via Javascript. Like triggering a server to send you more HTML by scrolling to the bottom of a page (to account for sites that implement lazy loading). This could come in handy for websites that require you to scroll to the bottom of an agreement before the "Agree" button is activated.

Social sharing for specific assets

I am developing an analytical app using NodeJS and Express and I would like to give the user the option to share the currently filtered graph along with a title and a sample description. I would like to have an option to share to Facebook, Twitter and Google +. I have done some research and I have managed to find a few libraries that were supposed to suite me. One of which was social-share (https://www.npmjs.com/package/social-share). The problem with this library is that I was unable to upload images to Facebook or Twitter, as well as the missing Google+ option.
The other library I have found is twit (https://github.com/ttezel/twit) which I still have not tried but either way it is for Twitter only.
After some time of trying to find a trivial solution, I started looking into the "build my own" option. I registered my app in the Facebook Developers console. I followed all the steps there to setup the SDK and the smple share code. The problem there was that the URL I wanted to share (http://127.0.0.1:3000/ or localhost at my case) was not "in the allowed domains for the application". I have tried a number if solutions for this error but none seemed to work. I have creadet a "Test app" under the original app in Facebook Dev Console. I have also tried creating an entirely new application for purely development purposes. (Note: in both previously stated caces I have switched the app ids obviously). I also tried the settings options for "Add platform" with "localhost" as the site URL. I have tried adding it as allowed domains and other options but I could not seem to get it to work.
What I also tried was the "Add This" option to share, leveraging the meta og: tags for image. The content is dynamically generated so I figured I should update the contents of the meta tags dynamically as well (using jQuery in my case). The problem I see there is the following: Facebook scrapes the page periodically and therefore the dynamic content from the og: tags is not fetched. Also the share button always used the information scraped from the url that I tried to share.
So after all this my questions are: Is there a trivial way in which I can have simple share buttons which the user can share the currently visible content (Highcharts graph) along with a title and text (prefilled by the app)? Is this supported for Facebook, Twitter and Google +?
Thank you in advance!

Retrieve Google results without using the Custom Search API

Recently I've been working on an idea that requires me to query Google Images and retrieve links for images matching that search term. My most promising candidate for a usable Google Images API was the Google Web Search API, but it looks like it's going to be going out of service as of tomorrow:
https://developers.google.com/web-search/docs/
The API that replaced it is the Google Custom Search API, but it's a little discouraging to use:
Google API Custom Search with Python - Programmatic Search Results
100 search results a day is a very strict limit; that's just four searches per hour. I also don't want to have to go through the hassle of creating some custom search bar that I'm never going to use except through Python
I decided to turn to parsing HTML directly from the results page. This presents a problem, though, because nowhere inside the page's HTML is there any direct link to the image, only referrer URLs. This is true of the javascript-enabled and javascript-disabled versions of Google Images (so even if Python spoofs javascript as enabled, nothing). I'm not sure where to go from here. Could anyone refer me to some obscure, updated library that I've somehow overlooked, or give me some pointers?
You could use Selenium Webdriver to actually execute the JavaScript and click on the images in the thumbnail view. Once an image has been opened, the link is in the DOM and you can scrape it from there. All Webdriver does is open an actual browser and simulate a user. You can even run it as a headless browser if you use xvfbwrapper. The downside is that even then, you will need all the dependencies of the browser you are using installed on your server.
However, scraping Google is against their terms of service and they will make an effort of blocking you as quickly as possible. So, unless you pass through the captchas (which are linked to sessions), you will possibly not be able to make a whole lot of searches before being blocked this way, either.

Chrome Extension: How to create? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am experienced in HTML and JavaScript but have never made a (real) Chrome Extension (other than the "Hello World' tutorial).
What I want to do is make an extension that adds functionality to viewing images. Basically I want a pieice of JavaScript to load when you go to a .jpg, .png, ect. page.
I couldn't get much out of the "Hello World" tutorial or the Docs and I've looked at code from XML Tree, but I'm having trouble understanding it.
I don't know where to go from here.
Since you're experienced in JavaScript and HTML, tell you what the best source is?
http://developer.chrome.com/extensions/getstarted.html
Documentation
The above link (Chrome Extension Documentation) is so simple to read once you get a hang of it. For example, I didn't know JavaScript when I created my first Chrome Extension (Reload all tabs). I recommend you to read the docs (will only take you an hour), and follow the steps that you need.
Make sure you understand the different UI's you can tap to
Browser Actions: You use browser actions to put icons in the main Chrome toolbar.
Context Menus: You use context menus to add items to Chromes context menu.
Desktop Notifications: Use desktop notifications to notify users that something is important.
Option Pages: If you want an options page, this is your guy!
Page Actions: If you want to override certain pages (New Tab, History, Bookmark Manager)
Make sure you realize there are many browser interactions that you can tap into:
Bookmarks: Access to your bookmarks
Cookies: Access to Cookies
History: Access to History
Management: Access to Extension Management
Tabs: Access to your Tabs
Windows: Access to your Windows (which has Tabs).
Make sure you understand the difference between Background Pages and Content Scripts, and their limitations.
Make sure you realize there are some neat functions in the Chrome.* API.
Make sure you understand permissions.
Many more
145 Chrome Questions I answered on Stackoverflow
If you want more examples, I have answered many questions regarding Chrome Extensions that might help you get started (145+ Questions Answered), for example, here are some of the more recent ones:
Content Script Skeleton
Send data from Background Page to Content Script
Communication with the embedding page, Simple fetching of the pages JS variable
Taking Screenshots in Chrome
Walkthrough building an extension
Executing JavaScript when a user clicks on a browser action.
How to capture selected text and send it to a web service
Walkthrough how to create an extension to access Disqus Comment Box
Walkthrough how to highlight the DIV that the mouse if hovering over
Walkthrough how to move to the top of the page extension
Walkthrough how to create a bubble overlay when you select text.
etc and 120 more answers for Chrome Extensions, the above is what I copied from the results on the first page. So a search in Google will get you many results.
Real open source extension I created
If you want to see real source code of the extensions I have written (some are super small, some are super big):
Reload all tabs extension
Open link in a foreground tab extension
HTML5 Haptics Chrome extension
Set Wallpaper extension
Prayer times extension
Facebook friend exporter extension
Proxy Anywhere extension
Resources
If you still want more resources, you can:
Read the documentation.
Read the Official Chromium Extension Mailing list
The unofficial Internet Relay Chatroom #chromium-extensions on irc.freenode.net
Google (Will bring you to Stackoverflow, or Quora)
I hope this helped!
well it’s not that tough to create a chrome extension ,anyone who has a basic understanding of HTML,CSS,Javascript can actually make one!
If you want to make a extension I have wrote an article on Medium it might be useful here's the link
Also I have attached my code on github here’s the link
Keep Learning!

Using Google Docs from web app

We have a requirement for people to be able to look at documents people have uploaded to us (mainly word, possibly some rtf) via our web app. We want the user to be able to open the docs inside the browser, but keep the original formatting and not have the need for another application (like word, acrobat etc).
We thought about using google docs to do this, there appears to be some batch uploading options to get stuff in there but does anyone know if we can use the API's to keep the user on our site without them having to login to google docs themselves, and keep them still on our website with re-directing to google docs to view them.
Cheers
There's an option to make documents public (Somewhere in Share->Advanced Options).
Using api you can get list of documents in your google docs account, you can even search em. In your app you could make a link to the document in google docs which opens in a new window. That way your user will never navigate away from your page. An alternative would be to use an IFrame, but it's considered bad practice.
A completely different approach could be to automatically generate and host a pdf each time someone uploads a file. There are scripts/programs which can do that, just call them after you receive a file.

Resources