Greasy Fork

微信公众号编辑器插件去隐藏广告

try to take over the world!

目前为 2018-12-14 提交的版本。查看 最新版本

// ==UserScript==
// @name         微信公众号编辑器插件去隐藏广告
// @namespace    http://tampermonkey.net/
// @version      0.7
// @description  try to take over the world!
// @author       You
// @match        https://mp.weixin.qq.com/cgi-bin/appmsg?t=media/appmsg_edit*
// @include https://www.135editor.com/*
// @grant        none
// ==/UserScript==

$(function() {
    if(location.host==="mp.weixin.qq.com"){
        setTimeout(function(){
            var toolbar = $('#js_toolbar_1')
            toolbar.append('<div id="removeAd" data-text="去广告" style="cursor:pointer"  class="edui-box edui-button edui-for-blockquote edui-default"><div class="button-name">清除</div></div>')
            var blackClassList = ['xmt-style-block','sougou','KolEditor','yead_editor','_135editor']
            var blackAttrList = ['data-tools','powered-by','data-author']
            $('#removeAd').click(function(){
                var dom = $('#ueditor_0').contents().find('*')
                dom.each(function(){
                    let _this = this
                    blackClassList.forEach(function(e){
                        $(_this).removeClass(e)
                    })
                    blackAttrList.forEach(function(e){
                        $(_this).removeAttr(e)
                    })
                    if($(this).attr('label')==='Powered by 135editor.com'){$(this).removeAttr('label')}
                })
            })

            $('#js_submit').hide()
            $('#js_preview').after('<span id="js_submit2" class="btn btn_input btn_primary r"><button type="button">保存</button></span>')
            $('#js_submit2').click(function(){
                var html = $('#ueditor_0').contents()
                let haveAd = html.find(blackClassList.map(e=>'.'+e).join(',')).length>0 || html.find(blackAttrList.map(e=>'['+e+']').join(',')).length>0 || html.find('[attr="Powered by 135editor.com"]').length>0
                if(haveAd){
                    if(confirm('当前文章存在隐藏广告(建议先清除广告再提交),是否强制保存')){
                        $('#js_submit').click()
                    }
                }else{
                    $('#js_submit').click()
                }
            })
        },2000)
    }else if(location.host==="www.135editor.com"){
        publishController.open_html_dialog = function(){}
        $('body').on('click','.editor-template-list>li',function(){
            console.log(1)
            if($(this).hasClass('vip-style')){
                let template = $(this).find('>section').html()
                console.log(template)
                insertHtml(template)
            }

        })
    }

});