Skip to content

Instantly share code, notes, and snippets.

@fdb713
Last active December 17, 2015 03:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fdb713/2aa8c8622b9cda0a7296 to your computer and use it in GitHub Desktop.
Save fdb713/2aa8c8622b9cda0a7296 to your computer and use it in GitHub Desktop.
mute tweets containing specific keyword.
// origin: @ayanamist
// ==UserScript==
// @name Twitter Timeline URL Expand
// @namespace Twitter-Timeline-URL-Expand
// @description Replace t.co href of A tag with real url.
// @match http://twitter.com/*
// @match https://twitter.com/*
// @version 1.1
// ==/UserScript==
(function (window) {
var document = window.document;
var OneTimeTrigger = function (func, delay) {
var timerCountdown = 0;
return function() {
setTimeout(function() {
timerCountdown -= 1;
if (timerCountdown == 0) {
func();
}
}, delay);
timerCountdown += 1;
};
};
var muteAll = function () {
Array.prototype.forEach.call(document.querySelectorAll(".js-tweet-text"),
function (node) {
if (node.innerHTML.match('ポスト')) {
$(node.parentNode.parentNode.parentNode).remove()
}
});
};
var trigger = OneTimeTrigger(muteAll, 100);
var MutationObserver = window.MutationObserver ? window.MutationObserver : window.WebKitMutationObserver;
if (typeof MutationObserver !== "undefined") {
var observer = new MutationObserver(trigger);
observer.observe(document, { childList: true, subtree: true });
}
else {
document.addEventListener("DOMNodeInserted", trigger, false);
document.addEventListener("DOMSubtreeModified", trigger, false);
}
muteAll()
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment