readoubleLaravelIndex

try to take over the world!

Verze ze dne 22. 11. 2018. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         readoubleLaravelIndex
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       tobigumo
// @match        https://readouble.com/laravel/*.*/*/*.html
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  const index = document.createElement('ul');

  const content_container = document.getElementById('contentContainer');
  const headers = content_container.querySelectorAll('h2,h3');
  const anchors = content_container.querySelectorAll('a[name]');

  headers.forEach( function (value, i) {

    if(value.tagName === 'H2') {
      const ul = document.createElement('ul');
      const li = document.createElement('li');
      const a = document.createElement('a');

      a.innerHTML = value.textContent;
      a.href = '#' + anchors[i].name;

      li.appendChild(a);
      index.appendChild(li);
    }

    if(value.tagName === 'H3') {
      const li = document.createElement('li');
      const a = document.createElement('a');

      a.innerHTML = value.textContent;
      a.href = '#' + anchors[i].name;

      li.appendChild(a);

      const last_li = index.lastElementChild;
      const last_element = last_li.lastElementChild;
      if (last_element.tagName === 'UL') {
        last_element.appendChild(li);
      }
      else {
        const ul = document.createElement('ul');
        ul.appendChild(li);
        last_li.appendChild(ul);
      }
    }

  });

  content_container.insertBefore(index, content_container.firstChild);

})();