mirror of https://github.com/Meekdai/Gmeek.git
added plugins english version
This commit is contained in:
parent
ac556c5cba
commit
d90a80cd94
|
|
@ -0,0 +1,100 @@
|
|||
function createTOC() {
|
||||
var tocElement = document.createElement('div');
|
||||
tocElement.className = 'toc';
|
||||
var contentContainer = document.getElementById('content');
|
||||
|
||||
const headings = contentContainer.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||
|
||||
if (headings.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
tocElement.insertAdjacentHTML('afterbegin', '<div class="toc-title">Table of Contents</div>');
|
||||
|
||||
headings.forEach(heading => {
|
||||
if (!heading.id) {
|
||||
heading.id = heading.textContent.trim().replace(/\s+/g, '-').toLowerCase();
|
||||
}
|
||||
const link = document.createElement('a');
|
||||
link.href = '#' + heading.id;
|
||||
link.textContent = heading.textContent;
|
||||
link.className = 'toc-link';
|
||||
link.style.paddingLeft = `${(parseInt(heading.tagName.charAt(1)) - 1) * 10}px`;
|
||||
tocElement.appendChild(link);
|
||||
});
|
||||
|
||||
tocElement.insertAdjacentHTML('beforeend', '<a class="toc-end" onclick="window.scrollTo({top:0,behavior: \'smooth\'});">Top</a>');
|
||||
contentContainer.prepend(tocElement);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
createTOC();
|
||||
var css = `
|
||||
.toc {
|
||||
position:fixed;
|
||||
top:130px;
|
||||
left:50%;
|
||||
transform: translateX(50%) translateX(320px);
|
||||
width:200px;
|
||||
border: 1px solid #e1e4e8;
|
||||
border-radius: 6px;
|
||||
padding: 10px;
|
||||
overflow-y: auto;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
max-height: 70vh;
|
||||
}
|
||||
.toc-title{
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
.toc-end{
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
visibility: hidden;
|
||||
}
|
||||
.toc a {
|
||||
display: block;
|
||||
color: var(--color-diff-blob-addition-num-text);
|
||||
text-decoration: none;
|
||||
padding: 5px 0;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e1e4e8;
|
||||
}
|
||||
.toc a:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
.toc a:hover {
|
||||
background-color:var(--color-select-menu-tap-focus-bg);
|
||||
}
|
||||
|
||||
@media (max-width: 1249px)
|
||||
{
|
||||
.toc{
|
||||
position:static;
|
||||
top:auto;
|
||||
left:auto;
|
||||
transform:none;
|
||||
padding:10px;
|
||||
margin-bottom:20px;
|
||||
}
|
||||
}`;
|
||||
|
||||
const style = document.createElement('style');
|
||||
style.textContent = css;
|
||||
document.head.appendChild(style);
|
||||
|
||||
window.onscroll = function() {
|
||||
const backToTopButton = document.querySelector('.toc-end');
|
||||
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
|
||||
backToTopButton.style="visibility: visible;"
|
||||
} else {
|
||||
backToTopButton.style="visibility: hidden;"
|
||||
}
|
||||
};
|
||||
|
||||
console.log("\n %c GmeekTOC Plugins https://github.com/Meekdai/Gmeek \n","padding:5px 0;background:#C333D0;color:#fff");
|
||||
});
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
function createVercount() {
|
||||
var postBody = document.getElementById('postBody');
|
||||
if (postBody){
|
||||
postBody.insertAdjacentHTML('afterend','<div id="busuanzi_container_page_pv" style="display:none;float:left;margin-top:8px;font-size:small;">Viewed<span id="busuanzi_value_page_pv"></span>times</div>');
|
||||
}
|
||||
var runday = document.getElementById('runday');
|
||||
runday.insertAdjacentHTML('afterend', '<span id="busuanzi_container_site_pv" style="display:none">Total viewed<span id="busuanzi_value_site_pv"></span>times • </span>');
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
createVercount();
|
||||
var element = document.createElement('script');
|
||||
element.src = 'https://vercount.one/js';
|
||||
document.head.appendChild(element);
|
||||
console.log("\n %c GmeekVercount Plugins https://github.com/Meekdai/Gmeek \n","padding:5px 0;background:#bc4c00;color:#fff");
|
||||
});
|
||||
Loading…
Reference in New Issue