// ==UserScript== // @name iTuringSubtitles // @namespace https://github.com/arrayJY/iTuringSubtitles // @version 0.2 // @description Add subtitles in ituring.com.cn. // @author arrayJY // @match https://www.ituring.com.cn/book/tupubarticle/* // @grant none // @run-at document-end // @require http://code.jquery.com/jquery-latest.js // @downloadURL none // ==/UserScript== (function () { "use strict"; $(document).ready(() => { const getIndex = (title) => title.split(" ")[0]; $("div.article-detail h2,h3").each(function () { $(this).attr("id", getIndex($.trim($(this).text()))); }); const subtitles = $("div.article-detail h2") .map(function () { const thirdSubtitles = $(this) .nextUntil("div.article-detail h2", "h3") .map(function () { return $.trim($(this).text()); }) .get(); const subtitle = { secondSubtitles: $.trim($(this).text()), thirdSubtitles, }; return subtitle; }) .get(); subtitles.shift(); const makeList = (s, t) => { return $("
") .append( $("") .text(s) .attr("href", `#${getIndex(s)}`) .css("font-size", "13px"), t ? $("