1

我正在开发一个 chrome 扩展,它总是有一个登录到 GitHub 的当前用户。为了切换用户,我想在我的扩展程序中有一个注销按钮,用于注销当前用户。

我试过简单

chrome.windows.create({'url':'https://github.com/logout'})

这将我带到 GitHub 注销页面,但仍然确认用户必须单击才能成功注销。我希望能够在后台或至少让用户注销,而无需他们点击额外的确认。

有什么想法吗?

4

2 回答 2

2

您可以检查此处提到的两种技术之一是否适合您:

即使在 Github 确认页面中方法的名称不同,这个想法仍然存在:如果您可以以某种方式覆盖/静音确认方法,您可以跳过该步骤。

于 2013-02-09T22:02:09.603 回答
2

工作解决方案

当我从外部页面调用https://github.com/logout时,它显示了一个带有提交/确认按钮的表单以注销。该表单没有 id 或类,但我设法使用

 document.getElementsByTagName('form')[1].submit();

Of course, this isn't ideal since it will break if github changes the layout of their logout page. Also, there is a delay between when the page is loaded and the form is submitted which isn't very user friendly. I'll update here if I find a better solution

于 2013-02-09T22:48:24.970 回答