Last active
August 29, 2015 14:08
-
-
Save lonelyelk/c325f37f1392ff6bfc8c to your computer and use it in GitHub Desktop.
UserScript для удаления записей о том, кто с кем стал друзьями из фильтров (списков).
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 fbBefriended | |
// @description Remove friending notifocations from list feed | |
// @author Sergey Kruk | |
// @license MIT | |
// @version 0.0.4 | |
// @match https://www.facebook.com/lists/* | |
// ==/UserScript== | |
(function (window, undefined) { | |
var main = window.document.getElementById("stream_pagelet"); | |
var observer = new MutationObserver(function (mutations) { | |
mutations.forEach(function (m) { | |
// console.log(m); | |
if ((m.target.parentNode) && (m.target.parentNode.id.indexOf("feed_stream") == 0) && (m.addedNodes.length > 0)) { | |
beFriend(m.target); | |
} | |
}); | |
}); | |
function beFriend (targetNode) { | |
var em = Array.prototype.filter.call(targetNode.querySelectorAll('span.fcg'), function (e) { | |
return /стали друзьями|теперь дружат/.test(e.textContent); | |
}); | |
Array.prototype.forEach.call(em, function (e) { | |
var d = e.parentNode; | |
while (d) { | |
if (d && d.hasAttribute('data-cursor') && d.parentNode) { | |
d.parentNode.removeChild(d); | |
return; | |
} else { | |
d = d.parentNode; | |
} | |
} | |
// console.log('not found'); | |
}); | |
// console.log(em.length); | |
} | |
observer.observe(main, { | |
subtree: true, | |
childList: true, | |
attributes: false, | |
characterData: false | |
}); | |
beFriend(main); | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment