<commit_before>// ==UserScript==
// @name           GitHub TOC Button
// @name:ru        Кнопка оглавления для GitHub страницы
// @namespace      https://spine3.org/gmscripts
// @description    Adds TOC button to GitHub page editor
// @include        http://github.com/*/wiki/*/_edit*
// @include        https://github.com/*/wiki/*/_edit*
// @version        1.0.0
// @grant          none
// ==/UserScript==

/*
   This code is based on the script created by Tomancaklab.
   See the original code at: http://tomancaklab.github.io/gfm-add-toc.user.js
*/

(function(){
  if (window.location.host != 'github.com' ||
      !window.location.pathname.match(/.*\/wiki\/.*\/_edit#?$/))
    return; // not editing a GitHub wiki page

  var textarea = document.getElementById('gollum-editor-body');
  var h1Button = document.getElementById('function-h1');
  if (!textarea || !h1Button) {
    console.log("Could not find text area or <h1> button");
    console.log(textarea);
    console.log(h1Button);
    return;
  }

  var self = this;

  var button = document.createElement('a');
  button.id = 'function-toc';
  button.href = '#';
  /* `button.className` changed according to StackOverflow advice:
     http://stackoverflow.com/questions/31844206/how-can-i-automatically-generate-tables-of-contents-in-a-github-wiki<commit_msg>Add author, license, and install/uninstall instructions<commit_after>// ==UserScript==
// @name           GitHub TOC Button
// @name:ru        Кнопка оглавления для GitHub страницы
// @namespace      https://spine3.org/gmscripts/
// @description    Adds TOC button to GitHub page editor
// @include        http://github.com/*/wiki/*/_edit*
// @include        https://github.com/*/wiki/*/_edit*
// @version        1.0.0
// @author         <NAME>
// @license        Creative Commons Attribution License
// @grant          none
// ==/UserScript==

/*
 * This file is a Greasemonkey user script.
 *
 * To install it for Firefox, you need the "Greasemonkey" plugin
 * (URL: http://greasemonkey.mozdev.org/).
 *
 * After you installed the Greasemonkey extension, restart Firefox and revisit
 * this script. Now you will see a new menu item "Install User Script"
 * in your tools menu.
 *
 * To uninstall this script from Greasemonkey, go to your "Tools" menu and
 * select "Manage User Scripts", then select this script from the list
 * and click uninstall.
 *
 * To install it under Chrome, you need the "Tempermonkey" plugin:
 * (URL: http://tampermonkey.net/)
 *
 * To uninstall the script from Tempermonkey, click on the plug-in button in
 * the Chrome toolbar, then select "Dashboard" menu item. In the Dashbaord
 * check the item with the script and click on the trash icon on the left.
 *
 * This code is based on the script created by Tomancaklab.
 * See the original code at: http://tomancaklab.github.io/gfm-add-toc.user.js
 *
 * Creative Commons Attribution License:
 * http://creativecommons.org/licenses/by/2.5/
*/

(function(){
  if (window.location.host != 'github.com' ||
      !window.location.pathname.match(/.*\/wiki\/.*\/_edit#?$/))
    return; // not editing a GitHub wiki page

  var textarea = document.getElementById('gollum-editor-body');
  var h1Button = document.getElementById('function-h1');
  if (!textarea || !h1Button) {
    console.log("Could not find text area or <h1> button");
    console.log(textarea);
    console.log(h1Button);
    return;
  }

  var self = this;

  var button = document.createElement('a');
  button.id = 'function-toc';
  button.href = '#';
  /* `button.className` changed according to StackOverflow advice:
     http://stackoverflow.com/questions/31844206/how-can-i-automatically-generate-tables-of-contents-in-a-github-wiki
{'fraction_non_alphanumeric': 0.1396103896103896, 'fraction_numerical': 0.00974025974025974, 'mean_word_length': 3.0715859030837005, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '943964', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1139, 'n_words': 328}