// ==UserScript==
// @name notion靠右悬浮目录
// @version 0.1.1
// @namespace https://www.notion.so/
// @description 将notion页面中的第一个目录模块放在右侧并且可以隐藏,未隐藏时鼠标放在该区域可以滑动目录
// @match https://www.notion.so/*
// @require https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js
// @grant none
// @downloadURL none
// ==/UserScript==
(function () {
'use strict';
// Your code here...
function addRightTOC(){
$("head").prepend(`
`)
$("body").prepend(`
`)
// Toggle button
$('.toggle-button').on('click', function () {
//updateOutline();
if (toc_open){
toc_open = false;
$('#panel').css("right", "20px");
$(".notion-table_of_contents-block").hide();
}else{
toc_open = true;
$('#panel').css("right", "276px");
$(".notion-table_of_contents-block").show();
//console.log($("#notion-app > div > div:nth-child(1) > div > div:nth-child(4) > main").height()-45);
$(".notion-table_of_contents-block").height($("#notion-app").height()-45);
}
});
}
let toc_open = false;
window.addEventListener('load', function () {
console.log(history);
let max_search_ms = 10000
let timer_id = setInterval(function () {
if ($(".notion-table_of_contents-block").length > 0) {
$(".notion-table_of_contents-block").hide();
addRightTOC();
clearInterval(timer_id);
} else {
max_search_ms = max_search_ms-500
if (max_search_ms<500){
clearInterval(timer_id);
}
}
}, 100);
}, false);
})();