Skip to content

Instantly share code, notes, and snippets.

@lonelyelk
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lonelyelk/c325f37f1392ff6bfc8c to your computer and use it in GitHub Desktop.
Save lonelyelk/c325f37f1392ff6bfc8c to your computer and use it in GitHub Desktop.
UserScript для удаления записей о том, кто с кем стал друзьями из фильтров (списков).
// ==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