您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a button create a page to your mycorrhiza header links
- // ==UserScript==
- // @name Mycorrhiza Create Page Button
- // @namespace https://mycorrhiza.wiki
- // @version 1.0
- // @description Adds a button create a page to your mycorrhiza header links
- // @author You
- // @icon https://em-content.zobj.net/source/microsoft/407/mushroom_1f344.png
- // NOTE: change this to your mycorrhiza instance.
- // @match https://mycorrhiza.wiki/*
- // @grant none
- // @license AGPL-3.0-or-later
- // ==/UserScript==
- (function() {
- 'use strict';
- function addToHeader() {
- const ul = document.querySelector('.top-bar__highlights');
- if (!ul) return;
- const li = document.createElement('li');
- li.className = 'top-bar__highlight';
- const a = document.createElement('a');
- a.href = '#';
- a.className = 'top-bar__highlight-link';
- a.textContent = 'New hypha';
- a.addEventListener('click', function(event) {
- event.preventDefault();
- // TODO: I want to make this part of the UI instead of a prompt
- const hyphaName = prompt("New hypha name:");
- if (hyphaName) {
- window.location.href = `/edit/${encodeHyphaName(hyphaName)}`;
- }
- });
- li.appendChild(a);
- // INFO: replace prepend with appendChild if you want the button at the end of the list
- ul.prepend(li);
- }
- function encodeHyphaName(hyphaName) {
- let encodedHyphaName = hyphaName.replace(' ', '_')
- return encodedHyphaName
- }
- addToHeader();
- })();