1
votes

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.

1

1 Answers

0
votes

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