我正在开发一款适用于Facebook的Google Chrome扩展程序。
我每10秒运行一次功能
myVar = setTimeout(search, 10);
搜索功能根据输入文本元素排列我的朋友故事,它将朋友(其名称出现在文本框中)放在顶部。 按下按钮时停止。
搜索功能:
function search()
{
var name = "";
var stories_parent = document.getElementsByClassName("tickerActivityStories")[0];
var last_moved_element = stories_parent.firstChild;
if(document.getElementById("srchTxt")!=null)
name = document.getElementById("srchTxt").value;
if(name != null && name!=" " && name !="")
{
isSearching = true;
var stories = document.getElementsByClassName("tickerFeedMessage");
for(i = currentStoryIndex+1 ; i < stories.length ; i++)
{ // a loop in stories searching for my friend stories
currentStoryIndex = i;
if(stories[i] != null && stories[i].firstChild != null)
{
var personName = stories[i].firstChild.innerText;//getting my friend name
if(personName == null)
stories[i].firstChild.remove();
if(personName!= null)
{
if(personName.toLowerCase().indexOf(name.toLowerCase()) == -1)
continue; //cheking if name isn't my friend name so continue
var element = stories[i].parentNode.parentNode.parentNode.parentNode.parentNode;
stories_parent.insertBefore(element, last_moved_element);
last_moved_element = element.nextSibling;
//moving my friend story up
}
}
}
fireEvent(document.getElementsByClassName("pam uiBoxLightblue tickerMoreLink uiMorePagerPrimary")[0],"click"); //load more stories pressing"show more"
myVar = setTimeout(search, 10);
}
}
问题在于,在运行该功能时,我无法在Facebook中向下滚动,除非点击该按钮。
如何同时运行该功能并浏览Facebook?