Greasy Fork is available in English.

繁簡自由切換

任意轉換網頁中的簡體中文與正體中文(默認簡體→正體),顯示漢字對應漢語拼音,自訂任意替換文本

< Valutazione su 繁簡自由切換

Recensione: Bene - lo script funziona

§
Pubblicato: 01/08/2023

使用腳本導致頁面失效

url: https://www.mcmod.cn/class/*.html
example: https://www.mcmod.cn/class/957.html
按 展开更多内容 後沒有反應

hoothinAutore
§
Pubblicato: 02/08/2023

這個站有段程式碼是單獨判斷“展开更多内容”這一串簡體字的

$(document).on("click", ".comment-row .fold", function() {
    var t = $(this).prev(".comment-row-text");
    $(this).text() == PublicLangData.comment.fold.down ? (t.css("max-height", "initial"),👈就是這段
    $(this).html('<i class="fas fa-chevron-up"></i>' + PublicLangData.comment.fold.up)) : (t.css("max-height", ""),
    $(this).html('<i class="fas fa-chevron-down"></i>' + PublicLangData.comment.fold.down))
});

想要展開繼續生效的話,可以新建一個脚本,添加 window.PublicLangData.comment.fold.down="展開更多内容"

§
Pubblicato: 07/08/2023


// 使用事件委托,将事件监听器添加到父元素上
document.addEventListener('click', function(event) {
// 检查点击的元素是否具有指定的类名
if (event.target.matches('.fold.text-muted')) {
// 执行点击按钮时的操作
window.PublicLangData.comment.fold.down = "展開更多內容";
}
});

是這樣子嗎?

§
Pubblicato: 08/08/2023


document.addEventListener('click', function(event) {
// 检查点击的元素是否具有指定的类名
if (event.target.classList.contains('fold') && event.target.classList.contains('text-muted')){
// 执行点击按钮时的操作
window.PublicLangData.comment.fold.down = "展開更多內容";
}
});

§
Pubblicato: 08/08/2023

具體代碼

document.addEventListener('click', function(event) {
    // 检查点击的元素是否具有指定的类名
    if (event.target.classList.contains('fold') && event.target.classList.contains('text-muted')){
        // 执行点击按钮时的操作
        window.PublicLangData.comment.fold.down = "展開更多內容";
    }
});

調試日誌

10:22:08.396 userscript.html?name=%25E7%25B9%2581%25E7%25B0%25A1%25E8%2587%25AA%25E7%2594%25B1%25E5%2588%2587%25E6%258F%259B.user.js&id=8a504a1e-160c-41be-9de4-b0f2e72b3a7e:1899 Uncaught TypeError: Cannot read properties of undefined (reading 'comment')

at HTMLDocument. (userscript.html?name=%25E7%25B9%2581%25E7%25B0%25A1%25E8%2587%25AA%25E7%2594%25B1%25E5%2588%2587%25E6%258F%259B.user.js&id=8a504a1e-160c-41be-9de4-b0f2e72b3a7e:1899:31)

(匿名) @ userscript.html?name=%25E7%25B9%2581%25E7%25B0%25A1%25E8%2587%25AA%25E7%2594%25B1%25E5%2588%2587%25E6%258F%259B.user.js&id=8a504a1e-160c-41be-9de4-b0f2e72b3a7e:1899

§
Pubblicato: 20/09/2023

url: https://www.mcmod.cn/class/*.html
example: https://www.mcmod.cn/class/9731.html
按 顯示更多成員 後沒有反應
/html/body/div[8]/div/div[2]/div[2]/div[1]/div[2]/div[2]/div[1]/ul/li[9]/a

hoothinAutore
§
Pubblicato: 28/09/2023

現在監聽到的文字變化會延遲半秒處理。具體到 mcmod 這個站,你可以連續點擊兩次顯示更多成員來觸發相關功能

Pubblica risposta

Accedi per pubblicare una risposta.