From f319dc92007f2bd1b9a56403456fd9ff3cc9aa5b Mon Sep 17 00:00:00 2001
From: Tianyu Wu
Date: Tue, 12 Jan 2021 18:10:34 -0500
Subject: [PATCH 1/6] [feature] enable full editor across the entire site
---
psnineplus.js | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/psnineplus.js b/psnineplus.js
index a7286cd..c7aa484 100644
--- a/psnineplus.js
+++ b/psnineplus.js
@@ -2849,6 +2849,20 @@
}
showCriticAverage();
+ const enableFullEditor = () => {
+ const editorButtons = '';
+ const editorColorButtonOnHover = () => { $('div.editor > div.dropdown.l').hover(() => { $('div.editor > div.dropdown.l').toggleClass('hover'); }); };
+ if (/(\/set\/qa)|(\/(topic|gene|qa|battle|trade|trophy)\/\d+)|(\/(psnid\/.+?|psngame\/\d+)\/comment)/.test(window.location.href)) {
+ $('div.editor.pr20').html(editorButtons);
+ editorColorButtonOnHover();
+ } else if (/\/set\/(gene|battle|trade)/.test(window.location.href)) {
+ $('form').append('');
+ $('textarea').replaceWith(`${editorButtons}
`);
+ editorColorButtonOnHover();
+ }
+ };
+ enableFullEditor();
+
// 右上角头像下拉框中增加插件设定按钮
if (window.localStorage) {
// 如果支持localstorage
From af17a39451051252032e8ddfc06d5e21b17db571 Mon Sep 17 00:00:00 2001
From: Tianyu Wu
Date: Tue, 12 Jan 2021 19:51:48 -0500
Subject: [PATCH 2/6] [fix] can't use $(this) in lambda function
---
psnineplus.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/psnineplus.js b/psnineplus.js
index c7aa484..2faba42 100644
--- a/psnineplus.js
+++ b/psnineplus.js
@@ -2851,7 +2851,7 @@
const enableFullEditor = () => {
const editorButtons = '';
- const editorColorButtonOnHover = () => { $('div.editor > div.dropdown.l').hover(() => { $('div.editor > div.dropdown.l').toggleClass('hover'); }); };
+ const editorColorButtonOnHover = () => { $('div.editor > div.dropdown.l').hover(function () { $(this).toggleClass('hover'); }); };
if (/(\/set\/qa)|(\/(topic|gene|qa|battle|trade|trophy)\/\d+)|(\/(psnid\/.+?|psngame\/\d+)\/comment)/.test(window.location.href)) {
$('div.editor.pr20').html(editorButtons);
editorColorButtonOnHover();
From 4b6d272405232b9fff50ed89e4c59390beaf1f24 Mon Sep 17 00:00:00 2001
From: Tianyu Wu
Date: Wed, 13 Jan 2021 08:42:19 -0500
Subject: [PATCH 3/6] [fix] redirection to
'psnine\.com\/set\/(gene|qa)\?ob=date'
---
psnineplus.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/psnineplus.js b/psnineplus.js
index 2faba42..5b210d6 100644
--- a/psnineplus.js
+++ b/psnineplus.js
@@ -106,7 +106,7 @@
// 站内使用HTTPS链接
if (settings.fixHTTPLinks && /^http:\/\//.test(window.location.href)) window.location.href = window.location.href.replace('http://', 'https://');
// 机因、问答页面按最新排序
- if (settings.listPostsByNew && /\/((gene)|(qa))($|(\/$))/.test(window.location.href)) {
+ if (settings.listPostsByNew && /(?
Date: Wed, 13 Jan 2021 09:02:43 -0500
Subject: [PATCH 4/6] [fix] conflict with character counter and preview
---
psnineplus.js | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/psnineplus.js b/psnineplus.js
index 5b210d6..fc34ce9 100644
--- a/psnineplus.js
+++ b/psnineplus.js
@@ -937,7 +937,7 @@
let newStr = str;
Object.keys(mapObj).forEach((i) => {
const re = new RegExp(i, 'g');
- newStr = str.replace(re, mapObj[i]);
+ newStr = newStr.replace(re, mapObj[i]);
});
return newStr;
};
@@ -960,6 +960,20 @@
'\\n': '
',
};
+ // 在全站范围启用完整编辑器工具
+ const enableFullEditor = () => {
+ const editorButtons = '';
+ const editorColorButtonOnHover = () => { $('div.editor > div.dropdown.l').hover(function () { $(this).toggleClass('hover'); }); };
+ if (/(\/set\/qa)|(\/(topic|gene|qa|battle|trade|trophy)\/\d+)|(\/(psnid\/.+?|psngame\/\d+)\/comment)/.test(window.location.href)) {
+ $('div.editor.pr20').html(editorButtons);
+ editorColorButtonOnHover();
+ } else if (/\/set\/(gene|battle|trade)/.test(window.location.href)) {
+ $('form').append('');
+ $('textarea').replaceWith(`${editorButtons}
`);
+ editorColorButtonOnHover();
+ }
+ };
+
/*
* 功能:在输入框下方追加输入内容预览框
* @param tag 可定位到输入框的标签名
@@ -1667,6 +1681,8 @@
if (/((gene|qa|topic|trade)($|\?))/.test(window.location.href)) {
autoPaging(settings.autoPaging);
}
+ // 在全站范围启用完整编辑工具栏
+ enableFullEditor();
// 页面:机因 > 发机因
if (/set\/gene/.test(window.location.href)) {
// 实时统计创建机因时候的文字数
@@ -2849,20 +2865,6 @@
}
showCriticAverage();
- const enableFullEditor = () => {
- const editorButtons = '';
- const editorColorButtonOnHover = () => { $('div.editor > div.dropdown.l').hover(function () { $(this).toggleClass('hover'); }); };
- if (/(\/set\/qa)|(\/(topic|gene|qa|battle|trade|trophy)\/\d+)|(\/(psnid\/.+?|psngame\/\d+)\/comment)/.test(window.location.href)) {
- $('div.editor.pr20').html(editorButtons);
- editorColorButtonOnHover();
- } else if (/\/set\/(gene|battle|trade)/.test(window.location.href)) {
- $('form').append('');
- $('textarea').replaceWith(`${editorButtons}
`);
- editorColorButtonOnHover();
- }
- };
- enableFullEditor();
-
// 右上角头像下拉框中增加插件设定按钮
if (window.localStorage) {
// 如果支持localstorage
From e583f2dad5777c10ca0d91824be3c7edcf07173c Mon Sep 17 00:00:00 2001
From: InfinityLoop
Date: Thu, 14 Jan 2021 01:25:27 +0900
Subject: [PATCH 5/6] fix: css style in editor page
- change text counter position
- fix padding right of editor
- docs indent
---
psnineplus.js | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/psnineplus.js b/psnineplus.js
index fc34ce9..ea2556d 100644
--- a/psnineplus.js
+++ b/psnineplus.js
@@ -900,11 +900,10 @@
};
fixLinksOnThePage();
- // 功能1-8:回复按钮hover触发显示
/*
- * 回复按钮hover触发显示功能函数
- * @param div 标签
- */
+ * 回复按钮hover触发显示功能函数
+ * @param div 标签
+ */
const hoverShowReply = (div) => {
const subClass = "span[class='r']";
$(`${div} ${subClass}`).css({
@@ -929,7 +928,8 @@
hoverShowReply("div[class$='ml64']");
}
- /* 将BBCode替换成对应html代码
+ /*
+ * 将BBCode替换成对应html代码
* @param str 原始BBCode输入
* @return str 转换后的html代码
*/
@@ -969,7 +969,7 @@
editorColorButtonOnHover();
} else if (/\/set\/(gene|battle|trade)/.test(window.location.href)) {
$('form').append('');
- $('textarea').replaceWith(`${editorButtons}
`);
+ $('textarea').parent().replaceWith(`${editorButtons}
`);
editorColorButtonOnHover();
}
};
@@ -980,7 +980,7 @@
*/
const addInputPreview = (tag) => {
$(tag).after(
- "",
+ "",
);
$(tag).keyup(() => {
$('#preview').html(replaceAll($(tag).val(), bbcode));
@@ -991,10 +991,10 @@
* 功能:实时统计创建机因时候的文字数
*/
const countInputLength = () => {
- $(".pr20 > textarea[name='content']").before(
+ $('div.alert-warning.pd10.mb10').after(
``,
+ 字数:0/600
+ `,
);
$(".pr20 > textarea[name='content']").keyup(() => {
const wordCount = $('.wordCount').text(
@@ -1015,9 +1015,6 @@
});
};
- // 评论框预览功能(等追加自定义设置后开放)
- // addInputPreview("textarea#comment[name='content']");
-
/*
* 问答标题根据回答状况着色
* @param isOn 是否开启功能
@@ -1069,10 +1066,10 @@
};
/*
- * 通过Ajax获取用户名片
- * @param data Ajax获取的数据
- * @param tip Tippy对象
- */
+ * 通过Ajax获取用户名片
+ * @param data Ajax获取的数据
+ * @param tip Tippy对象
+ */
const getUserCardByAjax = (data, tip) => {
const reg = /[\s\S]*<\/body>/g;
const html = reg.exec(data)[0];
From 5e9827e4cee365288d4eeb026414ef88172ec348 Mon Sep 17 00:00:00 2001
From: Tianyu Wu
Date: Wed, 13 Jan 2021 11:41:17 -0500
Subject: [PATCH 6/6] [fix] redirection to
'psnine\.com\/game\/\d+\/(gene|qa)\?ob=date'
---
psnineplus.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/psnineplus.js b/psnineplus.js
index ea2556d..278c5bb 100644
--- a/psnineplus.js
+++ b/psnineplus.js
@@ -106,7 +106,7 @@
// 站内使用HTTPS链接
if (settings.fixHTTPLinks && /^http:\/\//.test(window.location.href)) window.location.href = window.location.href.replace('http://', 'https://');
// 机因、问答页面按最新排序
- if (settings.listPostsByNew && /(?