Greasy Fork

Greasy Fork is available in English.

编程猫html修复

编程猫html修复,对iframe/embed进行了防范

当前为 2024-08-29 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         编程猫html修复
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  编程猫html修复,对iframe/embed进行了防范
// @author       Fantasy
// @match        https://shequ.codemao.cn/*
// @match        https://kitten4.codemao.cn/*
// @grant        none
// @require      https://code.jquery.com/jquery-3.6.0.min.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/jquery.cookie.min.js
// @license MIT
// @icon         https://static.codemao.cn/FjCi6RLz1-HB5C47m7M_0gZqJNDG
// @run-at       document-end
// ==/UserScript==

console.log('编程猫html修复已启用')

function edit_html(){
    $('.r-community-r-detail--forum_content,.r-community-r-detail-c-comment_item--content').each(function(){
        let old_content_str = $(this).html().replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/<(embed|iframe)[^>]*?(src=[^>]*?work[^>]*?|style=[^>]*?position[^>]*?)[^>]*?>/gi,'').replace('<p style="color:orange">【检测到html格式排版,已自动修复】</p>','')
        $(this).text('').append(`${old_content_str} ${old_content_str.includes('<') ? '<p style="color:orange">【检测到html格式排版,已自动修复】</p>' : ''}`)
    })


}

function wait_for_js(fun,selecter){
   let wait_js = setInterval(function(){
        if($(selecter).length !== 0){
            clearInterval(wait_js)
            fun()
        }
    })
}
if(window.location.href.includes("https://shequ.codemao.cn/wiki") ||window.location.href.includes("https://shequ.codemao.cn/community/")){
    setInterval(edit_html,100)
}