MCPcopy Create free account
hub / github.com/XIU2/UserScript / replyCustom

Function replyCustom

Hostloc-Enhanced.user.js:351–404  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

349 };
350 // 回复自定义
351 function replyCustom(type) {
352 switch (type) {
353 case 'forum': // 各版块帖子列表的预览帖子
354 replyCustom_0(); // 预览帖子 快速回复(底部)
355 replyCustom_1(); // 预览帖子 回复(悬浮)
356 break;
357 case 'thread': // 帖子内
358 replyCustom_1(); // 快速回复(悬浮)
359 replyCustom_2(); // 回复框(底部)
360 break;
361 case 'reply': // 高级回复
362 replyCustom_3();
363 break;
364 }
365 function replyCustom_0() {
366 let vfastpost = e => {
367 if (e.target.nodeType == 1 && e.target.innerHTML && e.target.innerHTML.indexOf('id="vfastpost"') > -1) {
368 let message = e.target.querySelector('input[name="message"]'), id = message.id.match(/\d+/g)[0];
369 message.parentNode.innerHTML = `<textarea type="text" name="message" id="vmessage_${id}" style="width: 99.8%;height: 30px;border: none;outline: none;font-size: 14px;overflow-y: hidden;"></textarea>`
370 document.getElementById(`vreplysubmit_${id}`).onclick = function () {
371 if (GM_getValue('menu_customLittleTail')) document.getElementById(`vmessage_${id}`).value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n');
372 }
373 }
374 }
375 document.addEventListener('DOMNodeInserted', vfastpost); // 监听插入事件
376 }
377 function replyCustom_1() {
378 let floatlayout_reply = e => {
379 if (e.target.nodeType == 1 && e.target.innerHTML && e.target.innerHTML.indexOf('id="floatlayout_reply"') > -1) {
380 // 快速回复(悬浮)中添加 URL 按钮
381 document.querySelector('#floatlayout_reply .fbld').insertAdjacentHTML('afterend', `<a href="javascript:;" title="点击给选中文字添加 url 标签(可正常显示为 URL)" class="flnk" style="filter: hue-rotate(83deg);" onclick="seditor_insertunit('post', '[url][i]', '[/i][/url]');doane(event);">URL</a>`);
382 document.getElementById('postsubmit').onclick = function () {
383 if (GM_getValue('menu_customLittleTail')) document.getElementById('postmessage').value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n');
384 }
385 }
386 }
387 document.addEventListener('DOMNodeInserted', floatlayout_reply); // 监听插入事件
388 // 快速发帖(各版块帖子列表底部)中添加 URL 按钮
389 document.querySelector('#fastposteditor .fbld').insertAdjacentHTML('afterend', `<a href="javascript:;" title="点击给选中文字添加 url 标签(可正常显示为 URL)" class="flnk" style="filter: hue-rotate(83deg);" onclick="seditor_insertunit('post', '[url][i]', '[/i][/url]');doane(event);">URL</a>`);
390 }
391 function replyCustom_2() { // 帖子底部的回复框
392 document.getElementById('fastpostsubmit').onclick = function () {
393 if (GM_getValue('menu_customLittleTail')) document.getElementById('fastpostmessage').value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n');
394 }
395 }
396 function replyCustom_3() {
397 let postsubmit = document.getElementById('postsubmit');
398 if (postsubmit && postsubmit.textContent === '\n参与/回复主题\n' || postsubmit && postsubmit.textContent === '\n发表帖子\n') {
399 postsubmit.onclick = function () {
400 if (GM_getValue('menu_customLittleTail')) document.getElementById('e_textarea').value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n');
401 }
402 }
403 }
404 }
405 // 监听插入事件(回帖间隔)
406 /*function replyIntervalDOMNodeInserted() {
407 let replyInterval = e => {

Callers 1

Calls 4

replyCustom_0Function · 0.85
replyCustom_1Function · 0.85
replyCustom_2Function · 0.85
replyCustom_3Function · 0.85

Tested by

no test coverage detected