Last active
August 29, 2015 14:05
-
-
Save SoftCreatR/4ed39fac08b10818ba55 to your computer and use it in GitHub Desktop.
Facebook Autopoke
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Facebook Autopoke | |
// @icon http://i.imgur.com/5ShnMqG.png | |
// @namespace http://www.softcreatr.de | |
// @author Sascha Greuel | |
// @description Automatically pokes back people. | |
// @version 1.9.0 | |
// @run-at document-end | |
// @grant none | |
// | |
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js | |
// @include /^https?://(.*)?facebook\.com(.*)?/ | |
// @exclude /^https?://(.*)?pixel.\facebook\.com(.*)?/ | |
// @exclude /^https?://(.*)?developers.\facebook\.com(.*)?/ | |
// @exclude /^https?://(.*)?facebook\.com/ajax/(.*)?/ | |
// @exclude /^https?://(.*)?facebook\.com/chat/(.*)?/ | |
// @exclude /^https?://(.*)?facebook\.com/pull(.*)?/ | |
// @exclude /^https?://(.*)?facebook\.com/ai\.php(.*)?/ | |
// @exclude /^https?://(.*)?facebook\.com/xti\.php(.*)?/ | |
// @exclude /^https?://(.*)?facebook\.com/l\.php(.*)?/ | |
// @exclude /^https?://(.*)?facebook\.com/plugins/(.*)?/ | |
// @exclude /^https?://(.*)?facebook\.com/(.*)/inline/?/ | |
// @exclude /^https?://(.*)?static\.ak\.facebook\.com(.*)?/ | |
// ==/UserScript== | |
(function ($) { | |
function autopoke() { | |
// 1st, we call the pokes page and fetch all pokes, if there are any | |
$.ajax({ | |
url: '/pokes', | |
dataType: 'html', | |
success: function (data) { | |
// Iterate through received pokes | |
$("a[href^='/pokes/inline/'], a[ajaxify^='/pokes/inline/']", data).each(function() { | |
if (window.location.host.toLowerCase().match(/m\.facebook\.com/)) { | |
var $that = $(this).attr('href'); | |
} | |
else { | |
var $that = $(this).attr('ajaxify'); | |
} | |
if ($that.indexOf('suggestion_type') == -1 && $that.indexOf('dom_id_hide') == -1) { | |
// Poke found. Send poke back | |
$.get($that); | |
} | |
}); | |
} | |
}); | |
} | |
// Runonce | |
setTimeout(function () { | |
autopoke(); | |
}, 1500); | |
// Start timer | |
setInterval(function () { | |
autopoke(); | |
}, 30000); // Repeat every 30 seconds | |
}(jQuery.noConflict(true))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just added some further excludes to avoid multiple instances of that script may cause a browser crash.