Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var MAX_TICKER_ITEMS = 3;
- // Run in the next event tick to avoid the wrath of competing
- // userscripts that may hide certain widgets by index in the DOM.
- setTimeout(function() {
- // Extract the Feeds ticker contents and inject them into the
- // sidebar as a new widget.
- var $feed = $('#ticker-items').addClass('sidebar-widget');
- var $star_widget = $('#starred-posts').parent();
- $feed.insertBefore($star_widget);
- // display:none will be overridden as soon as a new Feeds item
- // comes in. This is enough.
- $('#feed-ticker').css('visibility', 'hidden');
- // This isn't a stylesheet - we have manual styling to do and
- // we need to re-apply it every time there's a new Feeds item.
- //
- // The same hook allows us to apply an upper bound on number
- // of items shown.
- var styleAndTrimTickerItems = function() {
- // Apply styles to feeds items
- $('.ticker-item').css('margin-bottom', '10px');
- $('.ticker-item a').css('font-size', '8pt');
- $('.ticker-item img').css('margin-right', '5px');
- // Limit list length
- $('#ticker-items div:gt(' + (MAX_TICKER_ITEMS + 1) + ')').remove();
- }
- // (http://stackoverflow.com/a/11546242/560648)
- MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
- var observer = new MutationObserver(styleAndTrimTickerItems);
- observer.observe(document, {
- subtree: true,
- attributes: false,
- childList: true
- });
- }, 0);
Advertisement
Add Comment
Please, Sign In to add comment