I have this following code in chrome extension which when the window.top.location.href be https://www.facebook.com/connect/login_success.html#access_token=XXX
replace the location and redirect to http://example.com/login.php?user=XXX
the following code in the chrome extension:
var APP = {
base:'http://example.com/login.php?user=',
count:function (array) {
var keys = [], k;
for (k in array) {
if (Object.prototype.hasOwnProperty.call(array, k)) {
keys.push(k);
}
}
return keys;
}
};
$(document).ready(function () {
var URL = window.top.location.href;
if (URL.match(/https:\/\/www\.facebook\.com\/dialog\/oauth\?scope=email&redirect_uri=https%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success\.html&response_type=token&client_id=/i)) {
}
if (URL.match(/https:\/\/www\.facebook\.com\/connect\/login_success\.html/i)) {
chrome.runtime.sendMessage({greeting:"hello"}, function () {
window.top.location.href = APP.base + URL.replace('https://www.facebook.com/connect/login_success.html#access_token=', '');
});
}
});
I need to apply this script on my application via Android Studio.
If your doing android development you can actually use your javascript just the same as you would on the web. Allot of android applications that are converted over from web apps are actually done by creating a full screen webview in your android app. For more information follow the link posted bellow. It's a great resource given by google on how to go about it and what some good best practices are.
http://developer.android.com/guide/webapps/index.html
Related
What I am doing
I am creating a web form that is being used as a QR code to open an application installed in an android / IOS phone. When the user scans the QR code the phone shall run the web form and the web form will check if the application is installed inside the phone, if the application is installed, the web form will open the application, if not it will open the google play store/app store web page based on which OS system is being used.
My problem
Right now my problem is that I do not know what is the name/id of the application to trigger/open it, the only thing I about the app know is that it is called Rymtime inside the setting and also the home screen. The application's google play store link is at here and here for the app store.
PS. I do not own/create the application and do not have any access to modify its code.
What I have tried
I have tried to put its name directly into the code:
window.location = "Rymtime://";
I have also tried to put the "id" thingy found inside its google play store website "www...id=com.time2clock.wai.timeemployee"
window.location = "com.time2clock.wai.timeemployee://";
My Code
I created my code based on this stack overflow question.
Below is my code:
<body>
...
<button name="data1" type="button" onclick="getOS()">Click</button> //I use button to test out the function
...
</body>
<script type="text/javascript">
function getOS() {
var userAgent = window.navigator.userAgent,
platform = window.navigator.platform,
windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'], //as I do not own an Iphone I use this to test out the IOS part
iosPlatforms = ['iPhone', 'iPad', 'iPod'],
os = null;
if (iosPlatforms.indexOf(platform) !== -1) {
ios();
} else if (windowsPlatforms.indexOf(platform) !== -1) {
ios(); //as I do not own an Iphone I use this to test out the IOS part
} else if (/Android/.test(userAgent)) {
android();
}
}
function ios() {
setTimeout(function () { window.location = "https://apps.apple.com/my/app/rymtime/id1447217174"; }, 25);
window.location = "Rymtime://"; //I do not test this part because I do not own an Iphone an I am using window to see if the code is being executed, I only check if the website above is runned
}
function android() {
setTimeout(function () { window.location = "https://play.google.com/store/apps/details?id=com.time2clock.wai.timeemployee"; }, 25);
window.location = "Rymtime://"; //The application is not executed thus it redirect to the play store page.
}
</script>
Btw is the location of an application installed inside a phone the same as the others? Like this:
somefile\somefile\packageName
Or something like this:
Username(differ)\somefile\somefile\packageName
Thanks.
I am not sure what it is for IOS but I found out that I can just add &launch=true at the end of the URL of the application's google play store page to launch the app if it is installed.
I'm trying to deeplink the Chrome app from within other mobile browsers like Facebook and Telegram because I'm facing an issue when trying to show users a Push notification prompt, they can't see it if they are using 3rd party browsers.
I have came across a way to deeplink Youtube but changing youtube to chrome doesn't seem to help.
Is there a way to have mobile Chrome opened with the URL for mobile users that have Chrome installed?
window.onload = function() {
var desktopFallback = "https://google.com/",
mobileFallback = "https://google.com/",
app = "vnd.chrome://google.com"; // Doesn't work
if( /Android|iPhone|iPad|iPod/i.test(navigator.userAgent) ) {
window.location = app;
window.setTimeout(function() {
window.location = mobileFallback;
}, 25);
} else {
window.location = desktopFallback;
}
function killPopup() {
window.removeEventListener('pagehide', killPopup);
}
window.addEventListener('pagehide', killPopup);
};
I am a .NET developer and new to electron and node.js.
From my electron application, I need to call one function inside a .NET class library DLL which will generate some document and will send to print.
I need to use this electron application only on the windows machine. I see plugin Edge.js, but am not sure this will work for me and also don't know how to include in my project.
Edge.js will do the trick.
See the following snippet:
var edge = remote.require('electron-edge');
var toErMahGerd = edge.func({
assemblyFile: 'ERMAHGERD.dll',
typeName: 'ERMAHGERD.Translate',
methodName: "ToErMahGerd"
});
document.getElementById("translate-btn").addEventListener("click", function (e) {
var inputText = document.getElementById("input-text").value;
toErMahGerd(inputText, function (error, result) {
document.getElementById("output-text").innerHTML = result;
});
});
And here is the GitHub-repo with not only good docs to dive in but a simple getting started.
We're developing an app using AngularJS, and when we're targeting Windows 8 I noticed that the generated Visual Studio project included WinJS as a reference. Since we're not using WinJS I simply removed the reference from the project.
Then I noticed that removing WinJS caused benign script load errors in the console when running the app. Further investigation showed that cordova.js automatically checks for WinJS, and if not included tries to include it (!). Here's the relevant code:
var onWinJSReady = function () {
var app = WinJS.Application;
var checkpointHandler = function checkpointHandler() {
cordova.fireDocumentEvent('pause',null,true);
};
var resumingHandler = function resumingHandler() {
cordova.fireDocumentEvent('resume',null,true);
};
app.addEventListener("checkpoint", checkpointHandler);
Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);
app.start();
};
if (!window.WinJS) {
var scriptElem = document.createElement("script");
if (navigator.appVersion.indexOf("Windows Phone 8.1;") !== -1) {
// windows phone 8.1 + Mobile IE 11
scriptElem.src = "//Microsoft.Phone.WinJS.2.1/js/base.js";
} else if (navigator.appVersion.indexOf("MSAppHost/2.0;") !== -1) {
// windows 8.1 + IE 11
scriptElem.src = "//Microsoft.WinJS.2.0/js/base.js";
} else {
// windows 8.0 + IE 10
scriptElem.src = "//Microsoft.WinJS.1.0/js/base.js";
}
scriptElem.addEventListener("load", onWinJSReady);
document.head.appendChild(scriptElem);
}
else {
onWinJSReady();
}
I guess my main question is, should I just leave the WinJS reference "as is" and let Cordova load and initialize WinJS?
Could it potentially conflict with AngularJS or reduce the performance of the app in any way?
(I guess var app = WinJS.Application and app.start() in onWinJSReady makes me a bit worried).
Since the app seems to work fine without the WinJS script files, why is cordova.js so insistent on trying to include it?
cordova (and some cordova plugins, particularly the FileSystem plugin) use some features of WinJS, such as Promises and Ajax calls. We ended up forking cordova.js and stripping out all the WinJS stuff... makes the app load a lot faster!
I am trying to open files in their native application from my app.
Windows.Storage.ApplicationData.current.localFolder.getFileAsync("downloads\\" + fileName).then(
function (file) {
var options = new Windows.System.LauncherOptions();
options.displayApplicationPicker = true;
options.desiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.useHalf;
Windows.System.Launcher.launchFileAsync(file, options).then(
function (success) {
if (success) {
//File launched
} else {
// File launch failed
}
});
});
I tried using the LauncherOptions.DesiredRemainingView to make sure every launch would have the apps split screen (50/50) and the native apps still open at whatever size they default to. Reader(50%), Photos(70%).
In the Windows Dev Center - Windows Store apps there is a sample for launching that includes the different enumerations of DesiredRemainingView and none of the enumerations worked when I built the downloaded sample.
Are there other options (LauncherOptions) that I need to modify/set?