English 中文(简体)
Facebook 自动login JS在控制台工作, 但不在 GM 脚本中工作
原标题:Facebook auto-login JS works in console but not in GM script

我试图为Facebook创建一个自动登录脚本, 而不是使用先前存在的脚本。 当我在 Firefox 和 Chrome 的 javascript 控制台运行下列代码时, 用户名和密码字段都会按预期填写 :

var username = "[email protected]";
var password = "password";
var f = document.getElementById("login_form");
f.elements.namedItem("email").value = username;
f.elements.namedItem("pass").value = password; 

但当我把它当作一个Greasemonkey脚本运行时,他们不填写:

// ==UserScript==
// @name           Auto Login for FB
// @namespace      hamsolo474
// @description    AutoLogin 
// @include        https://www.facebook.com
// ==/UserScript==
var username = "[email protected]";
var password = "password";
var f = document.getElementById("login_form");
f.elements.namedItem("email").value = username;
f.elements.namedItem("pass").value = password; 

我通过 rel=“nofollow”这个链接 ,但似乎没有帮助。这是我在其他网站上成功运行的GM脚本的衍生物, 我不明白为什么它不在这里工作, 任何帮助都会非常感激!


EDIT:
I have also tried an alternate method of:

var username = "[email protected]";
var password = "password";
document.getElementsByName("email", "input")[0].value = username;
document.getElementsByName("pass", "input")[0].value = password;

做为标本和:

// ==UserScript==
// @name           Auto Login for FB
// @namespace      hamsolo474
// @description    AutoLogin 
// @include        https://www.facebook.com
// ==/UserScript==
var username = "[email protected]";
var password = "password";
document.getElementsByName("email", "input")[0].value = username;
document.getElementsByName("pass", "input")[0].value = password;

作为全球机制, 非常像我的第一种方法, 它在联署材料控制台工作 火狐和铬, 但对于全球机制也不行。

最佳回答

问题似乎在于 包括 指令设置不正确。 使用 :

// ==UserScript==
// @name           Auto Login for FB
// @namespace      hamsolo474
// @description    AutoLogin 
// @include        http://www.facebook.com/*
// @include        https://www.facebook.com/*
// ==/UserScript==
var username = "[email protected]";
var password = "password";
var f = document.getElementById("login_form");
f.elements.namedItem("email").value = username;
f.elements.namedItem("pass").value = password; 

anyone 代码文件中嵌入账户信息总是一个坏主意。

如果您只想让自己更容易进入Facebook账户, 使用 secure Login add-on , 就能更好、更安全。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签