我想将我的电子邮件从不太可靠的提供商(比如说 X)转移到 Gmail。 不幸的是,电子邮件提供商不允许文件夹导出或直接 IMAP 链接。
我唯一能做的就是通过 POP3 将 Gmail 连接到 X,这样 X 收件箱中的所有内容都会复制到 Gmail。
这个我已经设置好了,它可以工作,但是当然 POP3 只扫描收件箱。
我在收件箱以外的其他文件夹中有数千封电子邮件,因此我需要先将它们移至收件箱。但是,我只能通过 X 的 web GUI 移动消息,每轮只能移动一页消息。
所以我必须打开保存的消息文件夹,单击“全选”,选择“收件箱”并单击“移动”,然后页面将重新加载,我需要再次执行此操作...数百次。
我创建了一个模拟这些操作的 Javascript 函数(假设为 MoveToInbox()),然后我在 Firefox 中打开了页面并启动了 Firefox Scratchpad。因此,我可以在 Scratchpad 中一直按 Ctrl+R,然后等待页面重新加载,然后再按一次,这样可以节省大约 50% 的时间。
但是,我想知道,如果我能以某种方式让 Scratchpad 与该选项卡一起工作,以便它等待页面重新加载,然后执行脚本,然后再次等待,从而消除所有手动重复性任务。
我想我可以用 window.addEventListener 以某种方式做到这一点,但这个对象似乎在页面重新加载时被清除,所以有什么我可以改用的东西吗?
最佳答案
我自己的快速回答是仅使用 Firefox 插件,例如 GreaseMonkey .
当然,解决方案会因情况而异,但我自己的是这个 GreaseMonkey Javascript:
// the function to select all messages and programmatically click on
// move button:
function moveToInbox()
{
selectAllCheckbox=document.getElementById("messagesForm")[0];
mailboxSelector=document.getElementsByName('targetMailbox')[0];
selectAllCheckbox.click(); // click on "select all" checkbox
mailboxSelector.selectedIndex=1; //specify that we are moving to inbox
inx.mail.mailbox.mailboxTransfer(); // execute provider's function for moving mail.
}
// This gets executed on any page that matches URL specified in Greasemonkey script properties
// I have put this to execute, if the URL is for the folder I want to move messages from.
messageList=document.getElementById("messagesForm")[0];
// in my case, if there are no more messages to move, the form is not created at all, so
// I can check for its existance, to determine if I need to execute moving.
if (messageList == null)
{
return;
}
else
{
moveToInbox();
}
关于javascript - 如何使用 Javascript 从 Firefox Scratchpad 控制其他窗口,即使它重新加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12706955/