Greasy Fork

Greasy Fork is available in English.

Narou Siori Button

Disable narou's new auto siori function and add a float siori button on page.

当前为 2024-08-10 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           Narou Siori Button
// @name:ja        なろうしおりボタン
// @namespace      http://greasyfork.icu/en/users/1264733
// @version        2024-08-10
// @description    Disable narou's new auto siori function and add a float siori button on page.
// @description:ja なろうの自動しおり機能を無効化、ページにフロート・しおり・ボタンを追加。
// @author         L337
// @license        MIT
// @match          *://ncode.syosetu.com/*/*
// @grant          none
// @require        https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js
// ==/UserScript==

(()=>{
	'use strict';

	// 自動しおり無効化
	// Install ublock origin or adblockplus then block narou's auto siori api below:
	// ||syosetu.com/favnovelmain/shioriupdateapi/

	// Create & append a float siori button
	$("body").append(`<button type="button" class="siori_btn">📌</button>`);
	const as_btn = $(".siori_btn");
	as_btn.css({ 'position': 'fixed', 'width': '44px', 'height': '44px', 'z-index': '9999', 'font-size': '200%', 'opacity': '50%', 'cursor': 'pointer', 'border': 'none', 'padding': 'unset', 'right': '2em', 'bottom': '2em' });

	// Check current page doesn't have siori
	if (!$('.js-siori').hasClass('is-active')) {
		// Check current page doesn't have siori info
		if (!$('input[name="siori_url"]').length) {
			// Replace 123456 with your userid numbers.
			const userid = "123456";
			let ninfo = $(".js-bookmark_updateconf_url").val();
			let novelid = ninfo.split('/')[6];
			let episode = ninfo.split('/')[8];
			let token = $('input[name="token"]').val();
			as_btn.append(`
				<input name="siori_url" type="hidden" value="https://syosetu.com/favnovelmain/ichiupdateajax/useridfavncode/${userid}_${novelid}/no/${episode}/?token=${token}">
			`);
		}

		as_btn.on('click' ,function() {
			let siori_url = $('input[name="siori_url"]').val();
			siori_url += '&callback=?';
			$.ajax({
				type:'get',
				url: siori_url,
				cache: false,
				dataType : 'jsonp',
				async:false,
				success: function(data, textStatus) {
					if (data.result == true) {
						//console.log('===V0===');
						$('.js-siori').addClass('is-active');
						// Hide siori button after success
						as_btn.css({ 'opacity': '0', 'cursor': 'auto' });
					}else{
						//console.log('===X1===');
					}
				},
				error: function(jqXHR, textStatus, errorThrown){
					//console.log('===X2===');
				}
			});
		});
	} else {
		// Hide siori button
		as_btn.css({ 'opacity': '0', 'cursor': 'auto' });
	}
})();