// ==UserScript== // @name NarouRefiner // @namespace https://greasyfork.org/ja/users/52455-aosanori8 // @version 0.6 // @description 「小説家になろう」を読みやすく設定 // @author aosanori8 // @require https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.js // @require https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.js // @match http://ncode.syosetu.com/* // @match http://novel18.syosetu.com/* // @license MIT // @grant none // @downloadURL none // ==/UserScript== /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ function(module, exports, __webpack_require__) { /// /// "use strict"; var novelViewWrapper_1 = __webpack_require__(1); var indexBoxWrapper_1 = __webpack_require__(2); var wordDirectionSelector_1 = __webpack_require__(4); var fontSelector_1 = __webpack_require__(6); var inputSize_1 = __webpack_require__(8); var inputNumber_1 = __webpack_require__(9); var colorPicker_1 = __webpack_require__(10); var sideMenu_1 = __webpack_require__(11); var context_1 = __webpack_require__(12); var color_1 = __webpack_require__(3); var utils_1 = __webpack_require__(5); var pathParts = location.pathname.split("/").filter(Boolean); if (pathParts.length >= 1) { var novelCode = pathParts[0], articleNum = pathParts[1]; ////////////////////////////////////////////////////////////////// // LocalStorageからグローバル設定、作品設定を読み込む ////////////////////////////////////////////////////////////////// var DEFAULT_GLOBAL_SETTINGS = { textColor: "#000", backgroundColor: "#FFF", wordDirection: "horizontal-tb", novelWidth: "95%", novelHeight: "100%", font: null, fontList: [], fontSize: "12px", fontWeight: 500, letterSpacing: "", // wordSpacing: "", lineHeight: "", kanjiMargin: "0px", kanjiSize: "100%", katakanaMargin: "0px", katakanaSize: "100%", serifMargin: "0px", serifSize: "100%", expandNaviLayout: true, expandNaviFont: true, expandNaviTypeSetting: false, expandNaviProportion: false }; var DEFAULT_SETTINGS = { toggles: [] }; var context_2 = new context_1.default(novelCode, DEFAULT_GLOBAL_SETTINGS, DEFAULT_SETTINGS); ////////////////////////////////////////////////////////////////// // 標準で用意された全てのカスタムレイアウトを解除する ////////////////////////////////////////////////////////////////// var $body = $('body'); var $novelColor = $('#novel_color'); var $novelContents = $('#novel_contents'); var $novelSubList = $('dl.novel_sublist2'); for (var _i = 0, _a = utils_1.range(1, 8); _i < _a.length; _i++) { var i = _a[_i]; var className = 'customlayout' + i; if ($body.hasClass(className)) $body.removeClass(className); if ($novelColor.hasClass(className)) $novelColor.removeClass(className); if ($novelContents.hasClass(className)) $novelContents.removeClass(className); if ($novelSubList.hasClass(className)) $novelSubList.removeClass(className); } ////////////////////////////////////////////////////////////////// // ナビゲーターの構築 ////////////////////////////////////////////////////////////////// $(document.head).append($("\n \n ")); var $customNavi = $("
"); $(".novelview_navi").prepend($customNavi); // ==== 色彩設定 var $customColorLabel_1 = $("
" + (context_2.readGlobalSetting("expandNaviColor") ? "▼" : "▶") + " \u30AB\u30E9\u30FC
"); $customNavi.append($customColorLabel_1); var $customColorContainer_1 = $("
"); $customNavi.append($customColorContainer_1); $customColorLabel_1.click(function (event) { $customColorContainer_1.slideToggle(function () { var isDisplayed = $customColorContainer_1.css("display") !== "none"; $customColorLabel_1.text((isDisplayed ? "▼" : "▶") + " カラー"); context_2.saveGlobalSetting("expandNaviColor", isDisplayed); }); }); // ---- 文字色 var textColor_1 = context_2.readGlobalSetting("textColor"); $("#novel_color").css({ "color": textColor_1 }); { var $textColorLabel = $("
\u6587\u5B57\u8272
"); $customColorContainer_1.append($textColorLabel); var textColorController = document.createElement("div"); ReactDOM.render(React.createElement(colorPicker_1.default, {color: textColor_1, onChange: function (color) { $("#novel_color").css({ "color": color }); }, onChangeComplete: function (color) { $("#novel_color").css({ "color": color }); textColor_1 = color; context_2.saveGlobalSetting("textColor", color); }}), textColorController); $customColorContainer_1.append(textColorController); } $customColorContainer_1.append($("
")); var hoverColorHSV = color_1.RGB.fromString(textColor_1).toHSV().applyContrasts(40); var hoverColor = hoverColorHSV.toRGB().getColorCode(); $(document.head).append($("\n \n ")); // ---- 背景色 var backgroundColor_1 = context_2.readGlobalSetting("backgroundColor"); $("body").css({ "background-color": backgroundColor_1 }); { var $backgroundColorLabel = $("
\u80CC\u666F\u8272
"); $customColorContainer_1.append($backgroundColorLabel); var backgroundColorController = document.createElement("div"); ReactDOM.render(React.createElement(colorPicker_1.default, {color: backgroundColor_1, onChange: function (color) { $("body").css({ "background-color": color }); }, onChangeComplete: function (color) { $("body").css({ "background-color": color }); backgroundColor_1 = color; context_2.saveGlobalSetting("backgroundColor", color); }}), backgroundColorController); $customColorContainer_1.append(backgroundColorController); } $customNavi.append($("
")); // サイドメニュー構築 var allowedAddresses = ["ncode.syosetu.com", "novel18.syosetu.com"]; if (allowedAddresses.indexOf(location.host) >= 0) { var sideAddress = location.protocol + "//" + location.host + "/" + novelCode; var sideMenu_2 = new sideMenu_1.default(context_2, sideAddress); document.addEventListener("mousemove", function (event) { if (event.pageX < 10 && !sideMenu_2.isSideMenuOpened) { sideMenu_2.showSideMenu(textColor_1, backgroundColor_1); } else if (event.pageX > sideMenu_1.default.menuSize && sideMenu_2.isSideMenuOpened) { sideMenu_2.closeSideMenu(); } }); } if ($("#novel_ex").length > 0) { ////////////////////////////////////////////////////////////////// // 目次ページ ////////////////////////////////////////////////////////////////// var backgroundColorHSV = color_1.RGB.fromString(backgroundColor_1).toHSV().applyContrasts(20); var notYetReadColorHSV = color_1.RGB.fromString(backgroundColor_1).toHSV().applyContrasts(10); var chapterTitleColor = backgroundColorHSV.toRGB().getColorCode(); var notYetReadColor = notYetReadColorHSV.toRGB().getColorCode(); var indexBoxWrapper = new indexBoxWrapper_1.default($("div#novel_ex + div.index_box")); indexBoxWrapper.reconstructIndex(context_2, chapterTitleColor); indexBoxWrapper.applyAlreadyReadOnIndex(context_2, notYetReadColor); } else if ($("#novel_honbun").length > 0) { ////////////////////////////////////////////////////////////////// // 本文ページ ////////////////////////////////////////////////////////////////// context_2.saveReadSetting("articleNum", new Date().toString()); // CSSを設定 $("#container") .find("#novel_contents, #novel_p, #novel_color") .css({ "width": "auto" }); // 変更を適用したい箇所を操作用クラスでラップ var novelViews_1 = [new novelViewWrapper_1.default($(".novel_subtitle"), $("#novel_p"), $("#novel_honbun"), $("#novel_a"))]; // ==== レイアウト var $customLayoutLabel_1 = $("
" + (context_2.readGlobalSetting("expandNaviLayout") ? "▼" : "▶") + " \u30EC\u30A4\u30A2\u30A6\u30C8
"); $customNavi.append($customLayoutLabel_1); var $customLayoutContainer_1 = $("
"); $customNavi.append($customLayoutContainer_1); $customLayoutLabel_1.click(function (event) { $customLayoutContainer_1.slideToggle(function () { var isDisplayed = $customLayoutContainer_1.css("display") !== "none"; $customLayoutLabel_1.text((isDisplayed ? "▼" : "▶") + " レイアウト"); context_2.saveGlobalSetting("expandNaviLayout", isDisplayed); }); }); // ---- 字送り・行送り var wordDirection_1 = context_2.readGlobalSetting("wordDirection"); { var $wordDirectionLabel = $("
\u5B57\u9001\u308A\u30FB\u884C\u9001\u308A
"); $customLayoutContainer_1.append($wordDirectionLabel); var wordDirectionController = document.createElement("div"); ReactDOM.render(React.createElement(wordDirectionSelector_1.WordDirectionSelector, {wordDirection: wordDirection_1, onChangeWordDirection: function (_wordDirection) { for (var _i = 0, novelViews_2 = novelViews_1; _i < novelViews_2.length; _i++) { var novelView = novelViews_2[_i]; novelView.changeWritingMode(_wordDirection, novelHeight_1); } wordDirection_1 = _wordDirection; context_2.saveGlobalSetting("wordDirection", _wordDirection); }}), wordDirectionController); $customLayoutContainer_1.append(wordDirectionController); } $customLayoutContainer_1.append($("
")); // ---- ページ横幅 var novelWidth_1 = context_2.readGlobalSetting("novelWidth"); { $customLayoutContainer_1.append($("
\u30DA\u30FC\u30B8\u6A2A\u5E45
")); var novelWidthController = document.createElement("div"); ReactDOM.render(React.createElement(inputSize_1.default, {value: novelWidth_1, onChange: function (sizeValue) { for (var _i = 0, novelViews_3 = novelViews_1; _i < novelViews_3.length; _i++) { var novelView = novelViews_3[_i]; novelView.changeWidth(sizeValue); } novelWidth_1 = sizeValue; context_2.saveGlobalSetting("novelWidth", sizeValue); }}), novelWidthController); $customLayoutContainer_1.append(novelWidthController); } $customLayoutContainer_1.append($("
")); // ---- ページ縦幅 var novelHeight_1 = context_2.readGlobalSetting("novelHeight"); { $customLayoutContainer_1.append($("
\u30DA\u30FC\u30B8\u7E26\u5E45
")); var novelHeightController = document.createElement("div"); ReactDOM.render(React.createElement(inputSize_1.default, {value: novelHeight_1, onChange: function (sizeValue) { for (var _i = 0, novelViews_4 = novelViews_1; _i < novelViews_4.length; _i++) { var novelView = novelViews_4[_i]; if (wordDirection_1.indexOf("vertical") === 0) { novelView.changeHeight(sizeValue); } else { novelView.changeHeight("auto"); } } novelHeight_1 = sizeValue; context_2.saveGlobalSetting("novelHeight", sizeValue); }}), novelHeightController); $customLayoutContainer_1.append(novelHeightController); } $customNavi.append($("
")); // ==== フォント var $customFontLabel_1 = $("
" + (context_2.readGlobalSetting("expandNaviFont") ? "▼" : "▶") + " \u30D5\u30A9\u30F3\u30C8
"); $customNavi.append($customFontLabel_1); var $customFontContainer_1 = $("
"); $customNavi.append($customFontContainer_1); $customFontLabel_1.click(function (event) { $customFontContainer_1.slideToggle(function () { var isDisplayed = $customFontContainer_1.css("display") !== "none"; $customFontLabel_1.text((isDisplayed ? "▼" : "▶") + " フォント"); context_2.saveGlobalSetting("expandNaviFont", isDisplayed); }); }); // ---- 書体設定 var font_1 = context_2.readGlobalSetting("font"); var fontList = context_2.readGlobalSetting("fontList"); { $customFontContainer_1.append($("
\u66F8\u4F53
")); var fontSelector = document.createElement("div"); ReactDOM.render(React.createElement(fontSelector_1.FontSelector, {font: font_1, fontList: fontList, onChangeFontListener: function (_font) { for (var _i = 0, novelViews_5 = novelViews_1; _i < novelViews_5.length; _i++) { var novelView = novelViews_5[_i]; novelView.changeFont(_font); } font_1 = _font; context_2.saveGlobalSetting("font", _font); }, onChangeFontListListener: function (fontList) { context_2.saveGlobalSetting("fontList", fontList); }}), fontSelector); $customFontContainer_1.append(fontSelector); } $customFontContainer_1.append($("
")); // ---- フォントサイズ var fontSize_1 = context_2.readGlobalSetting("fontSize"); { $customFontContainer_1.append($("
\u6587\u5B57\u30B5\u30A4\u30BA
")); var fontSizeController = document.createElement("div"); ReactDOM.render(React.createElement(inputSize_1.default, {value: fontSize_1, onChange: function (sizeValue) { for (var _i = 0, novelViews_6 = novelViews_1; _i < novelViews_6.length; _i++) { var novelView = novelViews_6[_i]; novelView.changeFontSize(sizeValue); } fontSize_1 = sizeValue; context_2.saveGlobalSetting("fontSize", sizeValue); }}), fontSizeController); $customFontContainer_1.append(fontSizeController); } $customFontContainer_1.append($("
")); // ---- 文字ウェイト var fontWeight_1 = context_2.readGlobalSetting("fontWeight"); { $customFontContainer_1.append($("
\u6587\u5B57\u30A6\u30A7\u30A4\u30C8
")); var fontWeightController = document.createElement("div"); ReactDOM.render(React.createElement(inputNumber_1.default, {value: fontWeight_1, min: 100, max: 1000, step: 100, onChange: function (sizeValue) { for (var _i = 0, novelViews_7 = novelViews_1; _i < novelViews_7.length; _i++) { var novelView = novelViews_7[_i]; novelView.changeFontWeight("" + sizeValue); } fontWeight_1 = sizeValue; context_2.saveGlobalSetting("fontWeight", sizeValue); }}), fontWeightController); $customFontContainer_1.append(fontWeightController); } $customNavi.append($("
")); // ==== 文字組み var $customTypeSettingLabel_1 = $("
" + (context_2.readGlobalSetting("expandNaviTypeSetting") ? "▼" : "▶") + " \u6587\u5B57\u7D44\u307F
"); $customNavi.append($customTypeSettingLabel_1); var $customTypeSettingContainer_1 = $("
"); $customNavi.append($customTypeSettingContainer_1); $customTypeSettingLabel_1.click(function (event) { $customTypeSettingContainer_1.slideToggle(function () { var isDisplayed = $customTypeSettingContainer_1.css("display") !== "none"; $customTypeSettingLabel_1.text((isDisplayed ? "▼" : "▶") + " 文字組み"); context_2.saveGlobalSetting("expandNaviTypeSetting", isDisplayed); }); }); // ---- 文字間隔 var letterSpacing_1 = context_2.readGlobalSetting("letterSpacing"); { $customTypeSettingContainer_1.append($("
\u6587\u5B57\u9593\u9694
")); var letterSpacingController = document.createElement("div"); ReactDOM.render(React.createElement(inputSize_1.default, {value: letterSpacing_1, onChange: function (sizeValue) { for (var _i = 0, novelViews_8 = novelViews_1; _i < novelViews_8.length; _i++) { var novelView = novelViews_8[_i]; novelView.changeLetterSpacing(sizeValue); } letterSpacing_1 = sizeValue; context_2.saveGlobalSetting("letterSpacing", sizeValue); }}), letterSpacingController); $customTypeSettingContainer_1.append(letterSpacingController); } $customTypeSettingContainer_1.append($("
")); // ---- 行間隔 var lineHeight_1 = context_2.readGlobalSetting("lineHeight"); { $customTypeSettingContainer_1.append($("
\u884C\u9593\u9694
")); var lineHeightController = document.createElement("div"); ReactDOM.render(React.createElement(inputSize_1.default, {value: lineHeight_1, onChange: function (sizeValue) { for (var _i = 0, novelViews_9 = novelViews_1; _i < novelViews_9.length; _i++) { var novelView = novelViews_9[_i]; novelView.changeLineHeight(sizeValue); } lineHeight_1 = sizeValue; context_2.saveGlobalSetting("lineHeight", sizeValue); }}), lineHeightController); $customTypeSettingContainer_1.append(lineHeightController); } // ---- 単語間隔 // let wordSpacing: string = context.readGlobalSetting("wordSpacing"); // { // // $customTypeSettingContainer.append($(``)); // // const wordSpacingController = document.createElement("div"); // ReactDOM.render( // { // console.log("Word Spacing: " + sizeValue) // for (const novelView of novelViews) { // novelView.changeWordSpacing(sizeValue); // } // wordSpacing = sizeValue; // context.saveGlobalSetting("wordSpacing", sizeValue); // }} />, // wordSpacingController // ); // // $customTypeSettingContainer.append(wordSpacingController); // // } $customNavi.append($("
")); // ==== プロポーション var $customProportionLabel_1 = $("
" + (context_2.readGlobalSetting("expandNaviProportion") ? "▼" : "▶") + " \u30D7\u30ED\u30DD\u30FC\u30B7\u30E7\u30F3
"); $customNavi.append($customProportionLabel_1); var $customProportionContainer_1 = $("
"); $customNavi.append($customProportionContainer_1); $customProportionLabel_1.click(function (event) { $customProportionContainer_1.slideToggle(function () { var isDisplayed = $customProportionContainer_1.css("display") !== "none"; $customProportionLabel_1.text((isDisplayed ? "▼" : "▶") + " プロポーション"); context_2.saveGlobalSetting("expandNaviProportion", isDisplayed); }); }); // ---- 漢字マージン調整 var kanjiMargin_1 = context_2.readGlobalSetting("kanjiSpacing"); { $customProportionContainer_1.append($("
\u6F22\u5B57\u30DE\u30FC\u30B8\u30F3
")); var kanjiMarginController = document.createElement("div"); ReactDOM.render(React.createElement(inputSize_1.default, {min: 0, max: 200, step: 1, value: kanjiMargin_1, onChange: function (sizeValue) { for (var _i = 0, novelViews_10 = novelViews_1; _i < novelViews_10.length; _i++) { var novelView = novelViews_10[_i]; novelView.changeKanjiMargin(sizeValue); } kanjiMargin_1 = sizeValue; context_2.saveGlobalSetting("kanjiMargin", sizeValue); }}), kanjiMarginController); $customProportionContainer_1.append(kanjiMarginController); } $customProportionContainer_1.append($("
")); // ---- 漢字サイズ調整 var kanjiSize_1 = context_2.readGlobalSetting("kanjiSize"); { $customProportionContainer_1.append($("
\u6F22\u5B57\u30B5\u30A4\u30BA
")); var kanjiSizeController = document.createElement("div"); ReactDOM.render(React.createElement(inputSize_1.default, {min: 0, max: 200, step: 1, value: kanjiSize_1, onChange: function (sizeValue) { for (var _i = 0, novelViews_11 = novelViews_1; _i < novelViews_11.length; _i++) { var novelView = novelViews_11[_i]; novelView.changeKanjiSize(sizeValue); } kanjiSize_1 = sizeValue; context_2.saveGlobalSetting("kanjiSize", sizeValue); }}), kanjiSizeController); $customProportionContainer_1.append(kanjiSizeController); } // ---- カタカナマージン調整 var katakanaMargin_1 = context_2.readGlobalSetting("katakanaSpacing"); { $customProportionContainer_1.append($("
\u30AB\u30BF\u30AB\u30CA\u30DE\u30FC\u30B8\u30F3
")); var katakanaMarginController = document.createElement("div"); ReactDOM.render(React.createElement(inputSize_1.default, {min: 0, max: 200, step: 1, value: katakanaMargin_1, onChange: function (sizeValue) { for (var _i = 0, novelViews_12 = novelViews_1; _i < novelViews_12.length; _i++) { var novelView = novelViews_12[_i]; novelView.changeKatakanaMargin(sizeValue); } katakanaMargin_1 = sizeValue; context_2.saveGlobalSetting("katakanaMargin", sizeValue); }}), katakanaMarginController); $customProportionContainer_1.append(katakanaMarginController); } $customProportionContainer_1.append($("
")); // ---- カタカナサイズ調整 var katakanaSize_1 = context_2.readGlobalSetting("katakanaSize"); { $customProportionContainer_1.append($("
\u30AB\u30BF\u30AB\u30CA\u30B5\u30A4\u30BA
")); var katakanaSizeController = document.createElement("div"); ReactDOM.render(React.createElement(inputSize_1.default, {min: 0, max: 200, step: 1, value: katakanaSize_1, onChange: function (sizeValue) { for (var _i = 0, novelViews_13 = novelViews_1; _i < novelViews_13.length; _i++) { var novelView = novelViews_13[_i]; novelView.changeKatakanaSize(sizeValue); } katakanaSize_1 = sizeValue; context_2.saveGlobalSetting("katakanaSize", sizeValue); }}), katakanaSizeController); $customProportionContainer_1.append(katakanaSizeController); } // ---- セリフマージン調整 var serifMargin_1 = context_2.readGlobalSetting("serifSpacing"); { $customProportionContainer_1.append($("
\u30BB\u30EA\u30D5\u30DE\u30FC\u30B8\u30F3
")); var serifMarginController = document.createElement("div"); ReactDOM.render(React.createElement(inputSize_1.default, {min: 0, max: 200, step: 1, value: serifMargin_1, onChange: function (sizeValue) { for (var _i = 0, novelViews_14 = novelViews_1; _i < novelViews_14.length; _i++) { var novelView = novelViews_14[_i]; novelView.changeSerifMargin(sizeValue); } serifMargin_1 = sizeValue; context_2.saveGlobalSetting("serifMargin", sizeValue); }}), serifMarginController); $customProportionContainer_1.append(serifMarginController); } $customProportionContainer_1.append($("
")); // ---- セリフサイズ調整 var serifSize_1 = context_2.readGlobalSetting("serifSize"); { $customProportionContainer_1.append($("
\u30BB\u30EA\u30D5\u30B5\u30A4\u30BA
")); var serifSizeController = document.createElement("div"); ReactDOM.render(React.createElement(inputSize_1.default, {min: 0, max: 200, step: 1, value: serifSize_1, onChange: function (sizeValue) { for (var _i = 0, novelViews_15 = novelViews_1; _i < novelViews_15.length; _i++) { var novelView = novelViews_15[_i]; novelView.changeSerifSize(sizeValue); } serifSize_1 = sizeValue; context_2.saveGlobalSetting("serifSize", sizeValue); }}), serifSizeController); $customProportionContainer_1.append(serifSizeController); } // $customNavi.append($(`