以编程方式登录/退出 Gmail 聊天,单击 Gmail 的跨度“链接”

发布于 2024-07-29 03:11:32 字数 1271 浏览 5 评论 0原文

在工作中,我使用 Gmail 的聊天功能,因为它是加密的并且可以记录聊天内容,而无需在硬盘上安装或保存任何内容。 在家里,我使用洋泾浜语言。 当我在家登录 GMail 时,我必须退出聊天,否则消息会出现在错误的位置。 当我在工作中登录 GMail 时,我必须重新登录才能聊天。

换句话说,当我在家启动 Firefox 时,我希望自动禁用 Gmail 的聊天功能。 当我在工作中启动 Firefox 时,我希望自动启用 Gmail 的聊天功能。

有没有办法使用 Greasemonkey 脚本或类似的脚本在特定计算机上强制登录和注销? 这看起来很简单; 只需跟随 URL 或模拟单击链接即可。 不幸的是,Gmail 不使用实际的链接。

注销时:

<span tabindex="0" role="link" action="si" class="az9OKd">Sign into chat</span>

登录时,在下拉菜单中:

<div tabindex="-1" id=":1mj" role="menuitem" class="oA" value="si"><div class="uQ c6"/>Sign into chat</div>

<div tabindex="-1" id=":8f" role="menuitem" class="oA" value="sia"><div class="uQ c5"/>Sign into AIM®</div>

<div tabindex="-1" id=":8e" role="menuitem" class="oA" value="so"><div class="uQ df"/>Sign out of chat</div>

在页面底部:

<span id=":im" class="l8 ou" tabindex="0" role="link">turn off chat</span>

<span id=":im" class="l8 ou" tabindex="0" role="link">turn on chat</span>

有人知道如何使用 JavaScript“单击”这些非链接或访问其功能吗? 我想“so”的意思是“退出”,“si”的意思是“登录”,“sia”的意思是“登录AIM”。 我可以以某种方式直接调用这些操作吗?

还有其他方法可以禁用聊天吗?

At work, I use Gmail's chat, since it's encrypted and logs chats without installing or saving anything to the hard drive. At home, I use Pidgin. When I log into GMail at home, I have to log out of chat, or messages will end up in the wrong place. When I log into GMail at work, I have to log back in to chat.

In other words, when I start Firefox at home, I want Gmail's chat disabled automatically. When I start Firefox at work, I want Gmail's chat enabled automatically.

Is there a way to use a Greasemonkey script or similar to force logging in and logging out on specific machines? It would seem simple enough; just follow a URL or simulate clicking a link. Unfortunately, Gmail doesn't use actual links.

While logged out:

<span tabindex="0" role="link" action="si" class="az9OKd">Sign into chat</span>

While logged in, in drop-down menu:

<div tabindex="-1" id=":1mj" role="menuitem" class="oA" value="si"><div class="uQ c6"/>Sign into chat</div>

<div tabindex="-1" id=":8f" role="menuitem" class="oA" value="sia"><div class="uQ c5"/>Sign into AIM®</div>

<div tabindex="-1" id=":8e" role="menuitem" class="oA" value="so"><div class="uQ df"/>Sign out of chat</div>

At bottom of page:

<span id=":im" class="l8 ou" tabindex="0" role="link">turn off chat</span>

<span id=":im" class="l8 ou" tabindex="0" role="link">turn on chat</span>

Anyone know how to "click" these non-links with JavaScript or access their functions? I would imagine that "so" means "sign out", "si" means "sign in", and "sia" means "sign in AIM". Can I somehow call these actions directly?

Is there some other alternative for disabling chat?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

用心笑 2024-08-05 03:11:32

我在 gmail 窗口和 Adium 中使用 gmail 聊天,当朋友发起聊天时,我会在两个窗口中收到他或她的消息,因此在两个不同的位置登录不是问题。

这对你不起作用吗?

编辑:
正如下面评论者所说,您可以破译 gmail 的混淆 javascript,以尝试找出链接是如何附加到 javascript 函数的,以及调用了哪些函数。 那么你不需要模拟点击链接,你只需要调用适当的javascript函数。

I use gmail chat both within a gmail window and using Adium, and when a friend initiates a chat I get his or her message in both windows, so being logged in in two separate places isn't a problem.

Does this not work for you?

EDIT:
As the commenter said below, you could decipher gmail's obfuscated javascript to try and find out how the links are attached to javascript functions, and which functions are called. Then you don't need to simulate a click on the link, you just need to call the appropriate javascript function.

断肠人 2024-08-05 03:11:32

我知道原来的帖子很旧,但我在这里发帖供参考。

var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("点击", true, true, 窗口,
0, 0, 0, 0, 0, 假, 假, 假, 假, 0, 空);
YourElement.dispatchEvent(evt);

调度事件参考来自:
https://developer.mozilla.org/en/DOM/element.dispatchEvent

I know the original post is old, but I'm posting here for reference.

var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
YourElement.dispatchEvent(evt);

dispatchEvent reference from:
https://developer.mozilla.org/en/DOM/element.dispatchEvent

我只土不豪 2024-08-05 03:11:32

如果不显示,人们还能和你聊天吗?

我在 gchat 上只有几个联系人,所以无法轻松测试...

    window.addEventListener('load', function() {
  if (unsafeWindow.gmonkey) {
    unsafeWindow.gmonkey.load('1.0', function(gmail) {
      function logOffChat() {
        var leftPane = gmail.getNavPaneElement().childNodes[0];
        var chat = leftPane.childNodes[3];

        chat.id = 'googleChatElement';
    chat.parentNode.removeChild(chat);
      }

      logOffChat();

    });
  }
}, true);

我的猜测是,它仍然会在后台运行所有内容,并且您会显示为已登录...

Can people still chat to you if it's not even displayed?

I only have a couple of contacts on gchat, so can't test easily...

    window.addEventListener('load', function() {
  if (unsafeWindow.gmonkey) {
    unsafeWindow.gmonkey.load('1.0', function(gmail) {
      function logOffChat() {
        var leftPane = gmail.getNavPaneElement().childNodes[0];
        var chat = leftPane.childNodes[3];

        chat.id = 'googleChatElement';
    chat.parentNode.removeChild(chat);
      }

      logOffChat();

    });
  }
}, true);

My guess is, it'll still run everything in the background and you'll appear logged in...

赢得她心 2024-08-05 03:11:32

我不确定您是否知道,您可以远程结束 Gmail 会话。 点击 Gmail 页面底部的链接:

上次帐户活动:blah blah 详细信息

I'm not sure if you're aware, but you can end a Gmail session remotely. Click the link that says this at the bottom of your Gmail page:

Last Account Activity: blah blah Details

时光沙漏 2024-08-05 03:11:32

*chatenabled.mail.google.com* 添加到 Adblock 的过滤器列表会阻止 Gmail 聊天连接。 这将解决我的问题,即使我无法弄清楚如何单击“链接”。

Adding *chatenabled.mail.google.com* to Adblock's filter list prevents Gmail chat from connecting. This will solve my problem, even though I wasn't able to figure out how to click the "link".

疯到世界奔溃 2024-08-05 03:11:32

可能是我不明白。 但是你能尝试使用 Selenium 来解决这个问题吗? 它是一个在 Web 应用程序中自动化功能测试的框架。

May be I do not understand. But can you try using Selenium to work this out somehow? Its an framework to automate functional testing in web apps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文