Commit b3c7f0fd authored by Tobias Zeumer's avatar Tobias Zeumer
Browse files

Twitter: Highlight promoted tweets - working != nice

parent e4abc318
// ==UserScript==
// @name Twitter: Highlight promoted tweets
// @namespace https://collaborating.tuhh.de/tobias.zeumer/Tampermonkey/
// @version 0.0.2
// @version 0.0.3
// @updateURL https://collaborating.tuhh.de/tobias.zeumer/Tampermonkey/raw/master/www/twitter/Twitter_-_Highlight_Promoted_Tweets.user.js xxx
// @description Promoted tweets are far to similar to regular tweets. Make them red! (Test only; bad implementation)
// @author Tobias Zeumer
......@@ -11,13 +11,13 @@
(function() {
'use strict';
// @see: https://dom.spec.whatwg.org/#interface-mutationobserver
// @see: https://medium.com/better-programming/js-mutationobserver-1d7aed479da2
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(function(mutations, observer) {
//console.log(mutations, observer);
mutations.forEach(function(mutation) {
//console.log(mutation);
// Check each added node for promo (well, this is @todo ...)
......@@ -26,20 +26,21 @@
filterTwitterPromo(mutation.addedNodes.NodeList);
}
});
});
});
// The closest "safe" node to the twitter timeline is main (?)
var obsTarget = document.querySelector('main');
//var obsTarget = document.querySelector('main'); // Tampermonkey exits with "not of type node"...?
var obsTarget = document;
var obsConfig = {
subtree: true,
childList: true,
attributes: false
}
observer.observe(obsTarget, obsConfig);
observer.observe(obsTarget, obsConfig);
function filterTwitterPromo(target) {
target = document; //check later how best to manage
var twitterTag = 'span';
var twitterTxt = 'Promoted';
......@@ -55,7 +56,7 @@
article.style.backgroundColor = 'red';
console.log('Tampermonkey - Twitter: Highlight promoted tweets. Found "Promoted"!')
}
});
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment