Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.