Greasy Fork

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

try to take over the world!

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

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

(function() {
  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']
      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){
              alert('请先去除广告再保存')
          }else{
              $('#js_submit').click()
          }
      })
  },2000)
})();