pageWorker 不适用于 Facebook 上的所有页面
我正在编写一个 Firefox 扩展来读取隐私设置。我使用 PageWorkers 浏览不同的网站。但是,有些网站可以正常查找,而其他网站则无法打开。
function visitWebsite(url, flowURL){
var profile_website = pageWorkers.Page({
contentURL: url,
contentScriptFile: [data.url('jquery-1.6.4.js'),
flowURL,
data.url('extract_algorithm.js'),
data.url('ProfileSettings/profile_controller.js')],
contentScriptWhen: "ready"
});
//event triggers, when all profile settings were loaded from a site from profile_controller
profile_website.port.on('profile_results', function(profile_results){
add_to_all_results(profile_results);
});
}
function checkProfileSettings(){
visitWebsite("http://www.facebook.com/editprofile.php?sk=basic", data.url('ProfileSettings/Flow_Site1.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=relationships", data.url('ProfileSettings/Flow_Site2.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=eduwork", data.url('ProfileSettings/Flow_Site3.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=philosophy", data.url('ProfileSettings/Flow_Site4.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=entertainment", data.url('ProfileSettings/Flow_Site5.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=sports", data.url('ProfileSettings/Flow_Site6.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=activities", data.url('ProfileSettings/Flow_Site7.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=contact", data.url('ProfileSettings/Flow_Site8.js'));
}
Flow_SiteX.js 包含读数参数,但我在 profile_controller 中使用 console.log($('.label').text())) 进行了测试.js。每个站点中至少有 1 个带有 .label
的类,因此应该有一个输出。网站的基本、关系、哲学、娱乐始终运行完美。但PageWorker似乎根本不开放体育或活动!?有时 eduwork 有效,有时则无效。 好吧,我不明白为什么有些网站可以工作,有些则不能...我尝试了仅针对体育项目的 checkProfileSettings()
,因为我认为内存或其他内容已满,但事实并非如此。也不工作...
谢谢! :)
编辑:我写了一些 Test
main.js
var data = require("self").data;
var pageWorkers = require("page-worker");
var timers = require("timers");
function TestvisitWebsite(url, flowURL){
var profile_website = pageWorkers.Page({
contentURL: url,
contentScriptFile: [data.url('jquery-1.6.4.js'),
data.url('script.js')],
contentScriptWhen: "ready"
});
}
function testcheck()
{
TestvisitWebsite("http://www.facebook.com/editprofile.php?sk=sports", "aaa");
}
var timeout = timers.setInterval(function()
{
testcheck();
}, 1000);
script.js:
function combobox_by_name(ID_of_name){
console.log("Testoutput - " + $('select[name=audience\\[' + ID_of_name + '\\]\\[value\\]] option:selected').text());
}
combobox_by_name(129991670408857);
好吧,有趣的输出如下所示:
Freunde 是德语,意思是“朋友”,是正确的输出,但只是有时!?当我尝试使用 http://www.facebook.com/editprofile.php?例如 sk=basic,它总是有效!
i'm writing a firefox extension to read out privacy settings. I use PageWorkers to navigate through different websites. However, some are working find and other sites won't open.
function visitWebsite(url, flowURL){
var profile_website = pageWorkers.Page({
contentURL: url,
contentScriptFile: [data.url('jquery-1.6.4.js'),
flowURL,
data.url('extract_algorithm.js'),
data.url('ProfileSettings/profile_controller.js')],
contentScriptWhen: "ready"
});
//event triggers, when all profile settings were loaded from a site from profile_controller
profile_website.port.on('profile_results', function(profile_results){
add_to_all_results(profile_results);
});
}
function checkProfileSettings(){
visitWebsite("http://www.facebook.com/editprofile.php?sk=basic", data.url('ProfileSettings/Flow_Site1.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=relationships", data.url('ProfileSettings/Flow_Site2.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=eduwork", data.url('ProfileSettings/Flow_Site3.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=philosophy", data.url('ProfileSettings/Flow_Site4.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=entertainment", data.url('ProfileSettings/Flow_Site5.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=sports", data.url('ProfileSettings/Flow_Site6.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=activities", data.url('ProfileSettings/Flow_Site7.js'));
visitWebsite("http://www.facebook.com/editprofile.php?sk=contact", data.url('ProfileSettings/Flow_Site8.js'));
}
The Flow_SiteX.js
contains the parameter for the readout, but I tested it with console.log($('.label').text()))
in the profile_controller.js. In every site are at least 1 class with .label
so there should be an output. The Sites Basic, Relationships, Philosophy, entertainment are always working perfectly. But the PageWorker seems not to open sports or activities at all!? Sometimes eduwork is working and sometimes it does not.
Well, I don't understand why some sites are working and some not... I tried the checkProfileSettings()
with only sports for example, because I thought the memory or something was full but it didn't work either...
Thank you! :)
Edit: I wrote a little Test
main.js
var data = require("self").data;
var pageWorkers = require("page-worker");
var timers = require("timers");
function TestvisitWebsite(url, flowURL){
var profile_website = pageWorkers.Page({
contentURL: url,
contentScriptFile: [data.url('jquery-1.6.4.js'),
data.url('script.js')],
contentScriptWhen: "ready"
});
}
function testcheck()
{
TestvisitWebsite("http://www.facebook.com/editprofile.php?sk=sports", "aaa");
}
var timeout = timers.setInterval(function()
{
testcheck();
}, 1000);
script.js:
function combobox_by_name(ID_of_name){
console.log("Testoutput - " + $('select[name=audience\\[' + ID_of_name + '\\]\\[value\\]] option:selected').text());
}
combobox_by_name(129991670408857);
well and the funny output looks like this:
Freunde is german for "friends" and is the correct output, however only sometimes!? And when I try it with http://www.facebook.com/editprofile.php?sk=basic for example, it works always!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是一个竞争条件(即 facebook 在就绪事件后的某个时间加载您正在寻找的元素)
It could be a race condition (ie facebook loads the element that you are looking for sometime after the ready event)