From d90a80cd941299dc49848a8309744ff15a40df0a Mon Sep 17 00:00:00 2001 From: just koala Date: Wed, 3 Sep 2025 16:11:18 +1000 Subject: [PATCH] added plugins english version --- plugins/GmeekTOC_en.js | 100 ++++++++++++++++++++++++++++++++++++ plugins/GmeekVercount_en.js | 16 ++++++ 2 files changed, 116 insertions(+) create mode 100644 plugins/GmeekTOC_en.js create mode 100644 plugins/GmeekVercount_en.js diff --git a/plugins/GmeekTOC_en.js b/plugins/GmeekTOC_en.js new file mode 100644 index 0000000..1d014c4 --- /dev/null +++ b/plugins/GmeekTOC_en.js @@ -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', '
Table of Contents
'); + + 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', 'Top'); + 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"); +}); diff --git a/plugins/GmeekVercount_en.js b/plugins/GmeekVercount_en.js new file mode 100644 index 0000000..6237eaa --- /dev/null +++ b/plugins/GmeekVercount_en.js @@ -0,0 +1,16 @@ +function createVercount() { + var postBody = document.getElementById('postBody'); + if (postBody){ + postBody.insertAdjacentHTML('afterend',''); + } + var runday = document.getElementById('runday'); + runday.insertAdjacentHTML('afterend', ''); +} + +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"); +}); \ No newline at end of file