Chrome Extension - Pass URL argument (google-chrome http://www.google.com) - javascript

I've developed a chrome extension/kiosk app that opens up Google Chrome in a "kiosk mode" with 4 navigation buttons, HOME, RELOAD, BACK and FORWARD. So it's basically an application that opens up Chrome in a window without Omnibox but added 4 buttons.
This is because the user should not be able to change URL or anything else. Just navigate via the web interface and the 4 simple buttons.
Now, this application/extension is packed with a hardcoded URL. Which means you can't change the URL.
in my browser.html I have the following code:
<webview src="http://www.example.com/" style="width:100%; height:100%"></webview>
and in my browser.js I have the following code:
document.querySelector('#home').onclick = function() {
navigateTo('http://www.example.com/');
};
As you can see the URL is hardcoded both in HTML file and the javascript file.
My question is. Can I change the URL so it's not hardcoded in the extension/kiosk app?
So if I type google-chrome --app-id="jlfmnfhdcdmkibjnbeajhedeoahajnfc" http://www.google.com
into a terminal or cmd, I would want google.com to be displayed.
There may be a simple solution or no solution at all. This is my first attempt at making a chrome extension/kiosk app. So I'm an amateur in this area.
If you want to take a look at the source code, then you can find it on github.

Related

On the Wix Velo platform, is code placed in the "Page" area publicly visible?

According to this article, code that is put in the Page area specifically is publicly accessible. They even include this image to demonstrate:
I have not been able to see code that is entered here on the published version of the site. Here is an example where I published a blank page with a code in the onReady function:
https://steven0790.wixsite.com/my-site/blank
When I go to this page and inspect and search, I can't find the code. I would expect it to be in a <script> tag.
I have also tried looking through links in the code in case this is saved in a .js file or something like that.
Can anyone confirm whether or not this code really is accessible?
Check the Console instead of the Elements tab in the browser developer tools. It will let you know which JS file contains your code.
Look for a message that looks something like this:
Running the code for the HOME page. To debug this code in your browser's dev tools, open cnric.js.
You can then open that file in your browser developer tools and see the code.

Get JavaScript alert in case of specific words on web page

Is it possible to get a JavaScript alert when there is a given word (or words) on a currently visited web page?
I have searched in all the Google extensions, but I haven't found it unfortunately.
Thank you in advance!
I created an extension for you. Just download and unzip the file then follow these instructions to install. (The load unpacked part)
Instructions for the plugin:
To change the words which it alerts for. You click on the details button in the extensions page and scroll down and click the Extension options button. You can also click the Extension icon in the web bar and click Options.
hopefully, this helps.
link to download on github
With help from stackoverflow I have found a script that works:
if ((document.documentElement.textContent || document.documentElement.innerText).indexOf('cows') > -1)
{
alert("Hello");
}
The only problem is: it works only once. After saving the JS code, the current page refreshes and it works. But when I reload the page manually, the JS code isn't executed. BTW; I'm using the extentions "Custom Javascript for Websites 2"

Google App Script Warning

I have created an app script using user account 1 and used the script on a Google site. When I view the site using user account 2 , I receive a warning message which can be dismissed.
I have made a copy of the same script on the same site, however there is no option to dismiss this script. I would like to know what would cause this problem as the new script is an exact copy of the old script.
Copy Script http://i.stack.imgur.com/R151l.jpg
Original Script http://i.stack.imgur.com/FIyhm.jpg
If you mean the warning DOES NOT APPEAR then it doesn't show up if you're logged in as the owner of this script (app).
If you made the copy from account2 and are viewing it from the same then you won't see it.
I have installed Chrome on iPhone 4 and script 1 does not work when I use the following lines to call my html page, however the same script works with Chrome installed on Android and PC.
Script1:
output.setSandboxMode(HtmlService.SandboxMode.NATIVE);
However, when I use the following code, it works.
Script 2:
output.setSandboxMode(HtmlService.SandboxMode.IFRAME);
Now, the problem with script 1 is that I get a warning which is dismissable (This application is created by another user.), with script 2 I cannot dismiss the warning. That is why I want to use script 1 universally.
Will someone help me know how can I make script 1 work on Chrome for iOS?

Avoid confirmation dialog for url scheme redirection in iOS9

To open a native app from Safari we are using a url scheme redirection like myapp://do/something.
I know at least two ways to achive this:
Inserting iframe with src attribute equal to desired url (works on iOS8 only, stopped working on iOS9)
Replacing window.location.href property with desired url (works for both iOS8 and iOS9)
The both ways work well for iOS8 and redirect a user immediately to the installed application without any confirmation dialog. But starting from iOS9 Safari began to show a confirmation dialog to make sure that a user really wants to open an app:
Code on the page from above screenshot is pretty simple:
<!DOCTYPE html>
<html>
<head></head>
<body>
<script>
window.location.href = 'fb://';
</script>
</body>
</html>
I found no any official description for this changes on apple's site. It seems to me that there is nothing we can do with this behaviour.
QUESTION: Is somebody already faced this problem? Any ideas how we can avoid this confirmation box in Safari?
The confirmation dialog was added to address known vulnerabilities in many apps with registered iOS URL Schemes. It prevents malicious web pages from invoking URL Schemes that cause apps to make transactions on the users behalf without their knowledge. I'm not aware of any way to disable it.
More details on the vulnerability can be found in this BSides Las Vegas presentation:
http://www.irongeek.com/i.php?page=videos/bsideslasvegas2014/pg10-ios-url-schemes-omg-guillaume-k-ross

Firefox extension: invoking function from webpage js

I'm trying to automate some boring, duplicated data entry into a web application at work.
I'm sorry if the answer is well known but I've spent hours in google trying to figure it out.
The problem is, in the web-based application none of the links are simple HTML, 'a href' type links, they use javascript.
I can see in one of the .js files for the website that the function invoked when a link is clicked is defined as follows
function sendEvent(eventtype, targetid, value)
...and with the Firefox debugger I can see that in order to do the simple page navigation I want to do, my extension has to invoke the websites js function as follows (the 'value' parm can be null)
sendEvent("click", "mx709")
I found this similar question. The suggested method is
content.wrappedJSObject.funcFromPage()
or
getBrowser().contentWindow.wrappedJSObject.funcFromPage();
... but running either of those lines in my extension doesn't seem to invoke the function and hence "click" the link I want clicked
EDIT 1 - in case it wasn't clear, the code I actually put into my extension was:
content.wrappedJSObject.sendEvent("click", "mx709[R:3]");
EDIT 2 - Also tried this, no dice. I have the Firefox debugger open, and a breakpoint on the top of the 'sendEvent()' function. Every time I click a link in this web app, I hit the breakpoint, when I try lines like the above (or the following), the breakpoint is not tripped
window.content.document.defaultView.wrappedJSObject.sendEvent("click", "mx709[R:3]");
The wrappedJSObject method should work.
Open up scratchpad and copy paste this:
var indexOfTabWithMyDocument = 1; //1 means 2nd tab, 0 is first tab
Services.wm.getMostRecentWindow('navigator:browser').gBrowser.tabContainer.childNodes[indexOfTabWithMyDocument].contentWindow.wrappedJSObejct.FUNCTIONTORUN()
Set the environment of scratchpad to browser. And run. It will work.

Categories

Resources