Fanfics.me header toggle

Replacing new (as of Feb 2020) fanfics.me header behaviour with the old one

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu betiği yüklemek için bir betik yöneticisi eklentisi yüklemeniz gerekecektir.

(Zaten bir betik yöneticim var, hadi yükleyelim!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name            Fanfics.me header toggle
// @name:ru         Переключатель панели-заголовка на fanfics.me
// @namespace       http://tampermonkey.net/
// @version         0.2
// @description     Replacing new (as of Feb 2020) fanfics.me header behaviour with the old one
// @description:ru  Заменяет новое (на февраль 2020) поведение панели-заголовка fanfics.me на старое
// @author          agreg
// @match           https://fanfics.me/read.php?*
// @grant           GM_getValue
// @grant           GM_setValue
// ==/UserScript==

(function() {
    'use strict';

    const pinIcon = "http://icons.iconarchive.com/icons/icons8/windows-8/128/Programming-Pin-icon.png";
    const iOS = navigator.userAgent.match(/iPhone|iPad|iPod/i);

    $('.ReadTextContainer').die(iOS == null ? 'click' : 'touchend');

    var hidden = () => GM_getValue('hidden', false);
    let redraw = () => ['.topbar2', '.topbar3'].forEach(s =>
      {document.querySelector(s).style.position = (!hidden() ? 'fixed' : 'absolute')});
    redraw();

    var pin = document.createElement('img');
    pin.src = pinIcon;
    pin.style = `position: fixed;  top: 100px;  right: 20px;  height: 25px;  border: 1px solid black;  cursor: pointer`;
    pin.onclick = () => {GM_setValue('hidden', !hidden());   redraw()}
    document.body.appendChild(pin);
})();