📜 ⬆️ ⬇️

Reader Mode for Habr

Happens that the text or images of a post on Habré are not located on the screen.

It would be convenient to be able to turn off the right panel (Live, tag cloud) when it is not needed.

Solution for Firefox under the cat
')


1) Install Greasemonkey
2) Add a simple script there Habrahabr.ru Reader Mode

Or install from source:
// ==UserScript==
// @name habr_reader_mode
// @namespace habr
// @include habrahabr.ru*
// @include http://*.habrahabr.ru/*
// ==/UserScript==

var prevWidth = null;

SwitchReaderMode(GM_getValue('readerModeEnabled', false));

function SwitchReaderMode(enabled)
{
var mainContent = document.getElementById('main-content');
var sidebar = document.getElementById('sidebar');

if (mainContent && sidebar)
{
if (enabled)
{
sidebar.style.display= 'none';
prevWidth = mainContent.style.width;
mainContent.style.width = '100%'
}
else
{
if (prevWidth == null)
return;
sidebar.style.display= 'block';
mainContent.style.width = prevWidth;
}
}
}

GM_registerMenuCommand("Habr -> Reader Mode", function(){
SwitchReaderMode(true);
GM_setValue('readerModeEnabled', true)
});

GM_registerMenuCommand("Habr -> Normal Mode", function(){
SwitchReaderMode(false);
GM_setValue('readerModeEnabled', false)
});


That's all.

Now in Tools -> Greasemonkey -> User Commands we have commands for managing the right panel.

ps. The script has just been written, in 5 minutes, most likely there is a wide field for improvements :)

UPD: Updated script. Added saving state when switching between pages.

Source: https://habr.com/ru/post/42449/


All Articles