rainer.adelstonegmail.com / Maximize Space for Netvibes Feeds

// ==UserScript==
// @name        Maximize Space for Netvibes Feeds
// @namespace   netvibes
// @description Reader experience enhancement
// @match       http://www.netvibes.com/dashboard/*
// @match       https://www.netvibes.com/dashboard/*
// @grant       none
// @version     2.0
// @license     MIT
// ==/UserScript==

( function ()
{
	const iframe_el_offset = 147,
		  articles_list    = document.getElementsByClassName( 'nv-line-item-renderer' ),
		  feeds_list       = document.getElementsByClassName( 'nv-treeview-streams' );
	let guid               = 0;

	let enhanceReadingExperience = () =>
	{
		if ( feeds_list.length === 0 || articles_list.length === 0 ) {
			setTimeout( enhanceReadingExperience, 500 );
		}
		else {

			for ( let i = 0; i < articles_list.length; i++ ) {

				if ( !articles_list[ i ]._guid ) {

					articles_list[ i ]._guid = guid;
					guid++;

					articles_list[ i ].addEventListener( 'click', maximizeIframe, false );
				}
			}

			if ( !feeds_list[ 0 ]._guid ) {

				feeds_list[ 0 ]._guid = guid;
				guid++;

				feeds_list[ 0 ].addEventListener( 'click', () =>
				{
					setTimeout( enhanceReadingExperience, 500 );
				}, false );
			}

			const articles_list_wrapper = document.getElementsByClassName( 'no-native-scrollbars' );

			if ( articles_list_wrapper.length > 2 && !articles_list_wrapper[ 2 ]._guid ) {

				articles_list_wrapper[ 2 ]._guid = guid;
				guid++;

				articles_list_wrapper[ 2 ].addEventListener( 'scroll', enhanceReadingExperience, false );
			}
		}
	};

	let maximizeIframe = () =>
	{
		const iframe_el = document.getElementsByTagName( 'IFRAME' );

		if ( iframe_el[ 0 ] && iframe_el[ 0 ].outerHTML !== "" && ( iframe_el[ 0 ].style.visibility !== "hidden" ) ) {

			const headline = document.getElementsByClassName( 'nv-item-renderer-content-wrapper' );

			if ( headline[ 0 ] ) {
				headline[ 0 ].style.display = 'none';
			}

			const item_headers = document.getElementsByClassName( 'item-header' );

			for ( let i = 0; i < item_headers.length; i++ ) {

				if ( item_headers[ i ].innerHTML === "" ) {

					item_headers[ i ].style.display = 'none';
					break;
				}
			}

			iframe_el[ 0 ].style.width      = '81vw';
			iframe_el[ 0 ].style.marginLeft = '-5vw';

			let checkOffset = setInterval( function ()
										   {
											   const iframe_offset  = Math.floor( Number( iframe_el[ 0 ].getBoundingClientRect().top ) );
											   const iframe_wrapper = document.getElementById( 'smartreader-feeds-main' );

											   if ( iframe_wrapper && iframe_el[ 0 ].clientHeight > 0 && iframe_el[ 0 ].style.visibility !== 'hidden' ) {

												   if ( iframe_offset > ( iframe_el_offset + 10 ) || iframe_offset < ( iframe_el_offset - 10 ) ) {

													   iframe_wrapper.style.width = iframe_wrapper.offsetWidth - 1 + 'px';

													   setTimeout( () =>
																   {
																	   iframe_wrapper.style.width = iframe_wrapper.offsetWidth + 1 + 'px';
																   }, 500 );
												   }

												   if ( !iframe_wrapper._guid ) {

													   iframe_wrapper._guid = guid;
													   guid++;

													   window.addEventListener( 'resize', function ()
													   {
														   iframe_wrapper.style.width = 'auto';
													   } );
												   }

											   }
											   else {
												   clearInterval( checkOffset );
											   }
										   }, 1000 );
		}
	};

	enhanceReadingExperience();
} )();