【发布时间】:2015-11-01 14:20:04
【问题描述】:
我在 chrome 扩展中有以下代码,当 window.top.location.href 是 https://www.facebook.com/connect/login_success.html#access_token=XXX
替换位置并重定向到http://example.com/login.php?user=XXX
chrome 扩展中的以下代码:
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=', '');
});
}
});
我需要通过 Android Studio 将此脚本应用于我的应用程序。
【问题讨论】:
标签: javascript android facebook google-chrome android-studio