Change submodule to directory
This commit is contained in:
parent
e20f32d1c8
commit
e7cc3c947f
4 changed files with 230 additions and 1 deletions
|
@ -1 +0,0 @@
|
|||
Subproject commit 4c8d5d5e2b5be46aeeb56f96fbc47b000b81805c
|
136
fb-tickerfilter/firefox/userscript.js
Normal file
136
fb-tickerfilter/firefox/userscript.js
Normal file
|
@ -0,0 +1,136 @@
|
|||
// ==UserScript==
|
||||
// @name Facebook Ticker Filter
|
||||
// @namespace com.facebook.tickerfilter
|
||||
// @description Add a fild for filtering ticker events
|
||||
// @include https://www.facebook.com/*
|
||||
// @include http://www.facebook.com/*
|
||||
// @include https://*/facebook.com/*
|
||||
// @include http://*.facebook.com/*
|
||||
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js
|
||||
// @version 1
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
//
|
||||
/*jslint browser:true*/
|
||||
(function () {
|
||||
var downcount = 0;
|
||||
var targetIDs = [
|
||||
'cecile.tostivint.9', // target
|
||||
'camillebriant', // target
|
||||
'lise.duchatelet', // target
|
||||
'BlandineSdAsterya', // target
|
||||
'perrine.bouveret.9', // target relative (cecile.tostivint.9)
|
||||
'peeters7', // interest
|
||||
'c.grusondaniel', // interest
|
||||
'gayane.adourian', // interest
|
||||
'amelie.valentin.75', // relative (cecile.tostivint.9)
|
||||
'jessehaug', // relative (cecile.tostivint.9)
|
||||
'sanjarbek.khodjaev', // relative (cecile.tostivint.9)
|
||||
'morgane\.parma', // relative (cecile.tostivint.9)
|
||||
];
|
||||
var targetRE = new RegExp('/(' + targetIDs.join('|') + ')');
|
||||
//var targetRE = /\/(cecile\.tostivint\.9)/;
|
||||
var scrollTicker;
|
||||
scrollTicker = function () {
|
||||
var ticker;
|
||||
var evt;
|
||||
var scroll;
|
||||
//ticker = document.getElementById('pagelet_ticker');
|
||||
ticker = document.getElementsByClassName('ticker_container').item(0).children.item(0).children.item(0);
|
||||
console.log(ticker);
|
||||
ticker.style.background = 'red';
|
||||
console.log('begin com.facebook.scrollTicker');
|
||||
downcount += 1;
|
||||
downcount = downcount % 100;
|
||||
scroll = 20;
|
||||
if (downcount === 0) {
|
||||
scroll *= -1;
|
||||
}
|
||||
evt = document.createEvent('UIEvents');
|
||||
// creates a scroll event that bubbles, can be cancelled,
|
||||
// and with its view and detail property initialized to window and 1,
|
||||
// respectively
|
||||
evt.initUIEvent('scroll', true, true, window, scroll);
|
||||
ticker.dispatchEvent(evt);
|
||||
console.log('debug1 com.facebook.scrollTicker');
|
||||
|
||||
/*
|
||||
evt = document.createEvent('MouseEvents');
|
||||
evt.initMouseEvent('DOMMouseScroll', // in DOMString typeArg,
|
||||
true, // in boolean canBubbleArg,
|
||||
true, // in boolean cancelableArg,
|
||||
window, // in views::AbstractView viewArg,
|
||||
10, // in long detailArg,
|
||||
0, // in long screenXArg,
|
||||
0, // in long screenYArg,
|
||||
0, // in long clientXArg,
|
||||
0, // in long clientYArg,
|
||||
0, // in boolean ctrlKeyArg,
|
||||
0, // in boolean altKeyArg,
|
||||
0, // in boolean shiftKeyArg,
|
||||
0, // in boolean metaKeyArg,
|
||||
0, // in unsigned short buttonArg,
|
||||
null
|
||||
// in EventTarget relatedTargetArg
|
||||
);
|
||||
ticker.dispatchEvent(evt);
|
||||
console.log('debug2 com.facebook.scrollTicker');
|
||||
*/
|
||||
/*
|
||||
evt = document.createEvent('MouseEvents');
|
||||
evt.initEvent('mousewheel', true, true);
|
||||
evt.wheelDelta = scroll;
|
||||
ticker.dispatchEvent(evt);
|
||||
*/
|
||||
console.log('end com.facebook.scrollTicker');
|
||||
};
|
||||
|
||||
function cleanStory(story, protection) {
|
||||
var hidden = 0;
|
||||
var storyLink;
|
||||
storyLink = story.children.item(0);
|
||||
if (targetRE.test(storyLink.href)) {
|
||||
console.log(storyLink.href);
|
||||
hidden = 1;
|
||||
} else if (story.style.display !== 'none') {
|
||||
// we must decide either to hide or to count
|
||||
if (!protection) {
|
||||
story.style.display = 'none';
|
||||
} else {
|
||||
hidden = 1;
|
||||
}
|
||||
}
|
||||
return hidden;
|
||||
}
|
||||
// magic filtering
|
||||
|
||||
function cleanTicker() {
|
||||
//var ticker = document.getElementById('pagelet_ticker');
|
||||
var tickerStories;
|
||||
var story_idx;
|
||||
var story;
|
||||
var visibleCount;
|
||||
var tickerLimit;
|
||||
|
||||
tickerLimit = 11;
|
||||
visibleCount = 0;
|
||||
console.log('begin com.facebook.cleanticker');
|
||||
tickerStories = document.getElementsByClassName('fbFeedTickerStory');
|
||||
for (story_idx = tickerStories.length - 1; story_idx >= 0; story_idx--) {
|
||||
story = tickerStories.item(story_idx); //.children[0];
|
||||
visibleCount += cleanStory(story, (visibleCount >= tickerLimit));
|
||||
}
|
||||
//for (story_idx = 0 ; story_idx < tickerStories.length; story_idx++) {
|
||||
//story = tickerStories.item(story_idx); //.children[0];
|
||||
//
|
||||
//visibleCount += cleanStory(story, (visibleCount >= tickerLimit));
|
||||
//}
|
||||
//console.log('end com.facebook.tickerfilter.cleanTicker');
|
||||
// send scrolldown events to ticker...
|
||||
|
||||
console.log('end com.facebook.cleanticker');
|
||||
}
|
||||
window.setInterval(cleanTicker, 1000);
|
||||
window.setInterval(scrollTicker, 300);
|
||||
}());
|
||||
|
4
fb-tickerfilter/phantomjs/credential.json.example
Normal file
4
fb-tickerfilter/phantomjs/credential.json.example
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"email": "xxx",
|
||||
"pass": "yyy",
|
||||
}
|
90
fb-tickerfilter/phantomjs/facebook.js
Normal file
90
fb-tickerfilter/phantomjs/facebook.js
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*jslint node:true,browser:true*/
|
||||
var fs = require('fs');
|
||||
var cookieFile = 'cookies.json';
|
||||
var credentialFile = 'credential.json';
|
||||
|
||||
|
||||
var casper = require('casper').create({
|
||||
pageSettings: {
|
||||
loadImages: false,//The script is much faster when this field is set to false
|
||||
loadPlugins: false,
|
||||
userAgent: 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function loadCredentials() {
|
||||
var credentials;
|
||||
var txt;
|
||||
console.log("loadCredential");
|
||||
if (fs.exists(credentialFile)) {
|
||||
txt = fs.read(credentialFile);
|
||||
credentials = JSON.parse(txt);
|
||||
}
|
||||
console.log("/loadCredential");
|
||||
return credentials;
|
||||
}
|
||||
|
||||
function readCookies(page) {
|
||||
console.log("readCookies");
|
||||
var cookies = JSON.parse(fs.read(cookieFile));
|
||||
page.cookies = cookies;
|
||||
console.log(cookies);
|
||||
}
|
||||
|
||||
function saveCookies(page) {
|
||||
console.log("saveCookies");
|
||||
var cookies = JSON.stringify(page.cookies);
|
||||
console.log(cookies);
|
||||
fs.write(cookieFile, cookies, 'w');
|
||||
}
|
||||
|
||||
//First step is to open Facebook
|
||||
casper.start().thenOpen("https://facebook.com", function() {
|
||||
readCookies(this.page);
|
||||
console.log("Facebook website opened");
|
||||
saveCookies(this.page);
|
||||
});
|
||||
|
||||
|
||||
//Now we have to populate username and password, and submit the form
|
||||
casper.then(function(){
|
||||
var credentials;
|
||||
credentials = loadCredentials();
|
||||
readCookies(this.page);
|
||||
console.log("Login using username " + credentials.email + " and password");
|
||||
|
||||
this.evaluate(function(credentials){
|
||||
document.getElementById("email").value = credentials.email;
|
||||
document.getElementById("pass").value = credentials.pass;
|
||||
document.getElementById("loginbutton").children[0].click();
|
||||
}, credentials);
|
||||
saveCookies(this.page);
|
||||
});
|
||||
|
||||
//Wait to be redirected to the Home page, and then make a screenshot
|
||||
casper.then(function(){
|
||||
console.log("Make a screenshot and save it as AfterLogin.png");
|
||||
this.wait(6000);//Wait a bit so page loads (there are a lot of ajax calls and that is why we are waiting 6 seconds)
|
||||
this.capture('AfterLogin.png');
|
||||
});
|
||||
|
||||
/*
|
||||
//Get all images greater than 100x100 pixels
|
||||
casper.then(function(){
|
||||
var images = this.evaluate(function(){
|
||||
var facebookImages = document.getElementsByTagName('img');
|
||||
var allSrc = [];
|
||||
var i;
|
||||
for(i = 0; i < facebookImages.length; i++) {
|
||||
if(facebookImages[i].height >= 100 && facebookImages[i].width >= 100){
|
||||
allSrc.push(facebookImages[i].src);
|
||||
}
|
||||
}
|
||||
return JSON.stringify(allSrc);
|
||||
});
|
||||
console.log(images);
|
||||
});
|
||||
*/
|
||||
|
||||
casper.run();
|
Loading…
Reference in a new issue