Is it possible to overload geolocation functions using Chrome extension? - google-chrome

I want to overload navigator.geolocation.getCurrentPosition and navigator.geolocation.watchPosition to simulate geolocation during
development. Is it possible to do it using Google Chrome extension?

You mean something like this?
navigator.geolocation.getCurrentPosition = function(successCallback, errorCallback) {
successCallback({coords:{lattitude:10, longitude:20}});
}
If it is just for your own needs then it would be much easier to just do it in your js code.
If you want to make extension out of it then:
This code needs to be injected on every page of your app (via content script) and put inside dynamically created <script> tag, otherwise you will be inside content script sandbox and your overwritten function will not be visible to the parent page.
You would need to run this code before your app uses geolocation. There is no easy solution for this.

Now there's a chrome extension that does just that - the manual geolocation chrome extension. It tries its best to inject the script before any other one.

I found the extension what you want:)
https://chrome.google.com/webstore/detail/change-geolocation/njjpmclekpigefnogajiknnheheacoaj

Related

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.

Web browser integration

I need to create a software solution, that will use browser capabilities to perform some tasks.
More specific, i will need to do the following:
Load some page (by URL)
Analyse generated content (DOM), i need to access dynamically generated page, not just initial HTML document
Do a screenshot of some region of the page and save it to a file
What is the best way to do this?
What existing browser would allow me to do this and how exactly? Generally i prefer Google Chrome or Mozilla Firefox.
You can do that using casperjs
It will allow you to load a webpage, then capture any area and save it to a file.
It allow also to play with DOM
You can create a Google Chrome extension to do that.
1.In the extension, you can load page or add listener to observer the tab activities.
2.You can execute scripts on the page loaded,even use jQuery to Analyse the dom.
3.You can use chrome.tabs.captureVisibleTab function to take a screenshot,And then use canvas to handle the screenshot image.
more details about Chrome extension develop:https://developer.chrome.com/extensions/getstarted.html

Dynamic redirection in Google Sites with HtmlService

I wish to make a redirection in a Google Apps Script embedded in a Google Site. I use HtmlService: when the user click a button, it starts a function containing window.location = adress_I_want_to_redirect.
Unfortunatly, it doesn't work. I tried with jQuery and $('location').href(adress_I_want_to_redirect) but it doesn't work either (quite logical ^^). Console displays The property 'href' is not writable.
Do you know an other way to do redirection which will work in GAS?
Thank you!
It may be that the Caja engine is preventing you from doing a redirection like this. You may need to use a regular anchor tag instead.

Communicate between isolated worlds (extension js and webpage js) on chrome extension

As you may know, js files on chrome extensions and pages cannot directly access each other and they run on isolated worlds.
However, I want to access some of the functions on a page and call those functions from the plugin.
And I do not want to make my own version of those functions.
I'm wondering if this is possible... Would appreciate all the answers.
EDIT: The functions are on the background page. Its a browser action extension.
more info: Basically, I have a context menu which creates a tab to submit url to a page. however, re-opening the page makes many tabs and opening so many pages takes time. So I am willing to call the javascript function on the page directly from the extension if one instance of the page is open already. And I have access to the page permission-wise.
TL;DR: Need a way to call a javascript function on a page (without copying it locally) from an extension.
Assuming you know the tab ID of the page whose function you want to call, you can use chrome.tabs.update(tabId, {url: 'javascript:functionNameHere()'}); from your extension page. This works because javascript: URLs are mapped to script execution in the main (i.e. page, not isolated) world.

Is it possible to run an userscript on chrome://chromewebdata/ in Google Chrome

I want to redirect from a page that always result in HTTP 500, to the new page for the website.
I have made the userscript but it doesn't run, because the page is chrome://chromewebdata/ not http://xxx.xxx/yyy
No, not using a user script.
I would suggest looking into a Chrome Extension using the experimental webNavigation API and the associated "onError" callback.
http://code.google.com/chrome/extensions/trunk/experimental.webNavigation.html#event-onErrorOccurred