如何使用Javascript从Firefox Scratchpad控制其他窗口,即使它重新加载?

如何使用Javascript从Firefox Scratchpad控制其他窗口,即使它重新加载?,javascript,firefox,reload,persistent,scratchpad,Javascript,Firefox,Reload,Persistent,Scratchpad,我想把我的电子邮件从一个有点不可靠的提供商(比如X)转到Gmail。 不幸的是,电子邮件提供商不允许文件夹导出或直接IMAP链接 我唯一能做的就是通过POP3将Gmail连接到X,这样X收件箱中的任何东西都可以复制到Gmail 这个我已经设置好了,它可以工作,但当然POP3只扫描收件箱 我在收件箱之外的其他文件夹中有数千封电子邮件,所以我需要先将它们移动到收件箱。但是,我只能通过X的web GUI移动消息,它只允许每转一页移动消息 因此,我必须打开保存的邮件文件夹,点击“全选”,选择“收件箱”并

我想把我的电子邮件从一个有点不可靠的提供商(比如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 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();
}

我自己的快速回答只是使用Firefox插件,比如

当然,解决方案在不同的情况下会有所不同,但我自己的解决方案是这个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();
}
使用iFrame 第一个问题是变量和函数在重新加载后丢失:
-将
src=“X”

现在跨域策略正在引发问题:
-将
src

然后,您可以使用
iframeId.contentDocument

例如: 导航到,使用Inspect元素添加iframe:

然后,您可以使用JavaScript对iframe执行任何操作:
someID.contentDocument.location.reload();
setTimeout('someID.contentDocument.getElementById('lst-ib')。value=“iframes rock”,1000)//您应该使用比setTimeout更好的方法来等待网站加载。

使用iFrame 第一个问题是变量和函数在重新加载后丢失:
-将
src=“X”

现在跨域策略正在引发问题:
-将
src

然后,您可以使用
iframeId.contentDocument

例如: 导航到,使用Inspect元素添加iframe:

然后,您可以使用JavaScript对iframe执行任何操作:
someID.contentDocument.location.reload();

setTimeout('someID.contentDocument.getElementById('lst-ib')。value=“iframes rock”,1000)//您应该使用比setTimeout更好的方法来等待网站加载。

也许可以看看其他解决方案谢谢,但问题是提供商X不提供IMAP连接,所以我无法通过启用Gmail的IMAP或提供商的IMAP将其链接到Gmail。也许可以看看其他解决方案谢谢,但关键是提供商X不提供IMAP连接,所以我无法将其链接到Gmail,无论是启用Gmail的IMAP还是提供商的IMAP;我三年前就这样做了,不幸的是我记不起很多细节。我确实记得,正如前面的答案所建议的,我使用了GreaseMonkey,但我现在几乎无法测试您的解决方案,因为我正在做完全不同的事情。希望你的回答能帮助别人。谢谢你;我三年前就这样做了,不幸的是我记不起很多细节。我确实记得,正如前面的答案所建议的,我使用了GreaseMonkey,但我现在几乎无法测试您的解决方案,因为我正在做完全不同的事情。希望你的回答能帮助别人。