Last active
December 17, 2015 03:09
-
-
Save fdb713/2aa8c8622b9cda0a7296 to your computer and use it in GitHub Desktop.
mute tweets containing specific keyword.
This file contains hidden or 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
// 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