本帖最后由 咸鱼鱼 于 2025-1-18 18:26 编辑
在最近非常火热的[安科安价] 卡塞尔·格尔的魔药店
我们需要频繁的进行骰点,虽然熟练的玩家可能已经记住了代码,但是输入起来也非常不方便,所以快速写了一个脚本用于快速骰点
@Name @Name @Match- // ==UserScript==
- // @name GM论坛快速骰点
- // @namespace http://tampermonkey.net/
- // @version 1.0
- // @description 在#fastpostat后添加骰子插入按钮
- // @author 你的名字
- // @match https://www.gamemale.com/thread-*
- // @match https://www.gamemale.com/forum.php?mod=viewthread&tid=*
- // @icon https://www.gamemale.com/template/mwt2/extend/img/favicon.ico
- // @grant none
- // ==/UserScript==
- (function () {
- 'use strict'
- // 自由更改默认值
- const 默认值 = 'd20'
- // 等待 DOM 加载完成
- window.addEventListener('load', function () {
- // 创建骰子插入链接
- const diceLink = document.createElement('a')
- diceLink.href = "javascript:;"
- diceLink.title = "插入骰子"
- diceLink.className = "fbld"
- diceLink.style.backgroundImage = 'url(https://www.gamemale.com/static/image/common/bb_dice.png)'
- diceLink.style.backgroundRepeat = 'no-repeat'
- diceLink.style.backgroundPosition = 'center'
- diceLink.style.scale = '0.8'
- diceLink.onclick = function (event) {
- if (typeof seditor_insertunit === 'function') {
- seditor_insertunit('fastpost', '[dice]' + 默认值, '[/dice]')
- } else {
- console.error('seditor_insertunit 函数未找到')
- }
- doane(event)
- }
- // 获取目标元素
- const fastpostat = document.querySelector("#fastpostat")
- // 将骰子插入链接添加到#fastpostat后面
- if (fastpostat) {
- fastpostat.insertAdjacentElement('afterend', diceLink)
- } else {
- console.error('未找到#fastpostat元素')
- }
- })
- })()
复制代码
如果喜欢的话,希望点个追随,你的追随是我更新的最大动力 |