沪江去除广告脚本

沪江词典去除首尾广告

// ==UserScript==
// @name         沪江去除广告脚本
// @name:zh  沪江词典去广告
// @description:zh-cn 沪江词典去除首尾广告
// @namespace Violentmonkey Scripts
// @match    http://www.hjdict.com/*
// @author    Tin Kyoku
// @create   2019-11-13
// @grant    none
// @version  1.1
// @run-at   document-end
// @namespace http://tampermonkey.net/
// @license         GPL-3.0-only
// @description 沪江词典去除首尾广告
// ==/UserScript==


window.onload = function(){
  var reg = new RegExp(/^[_]{1}[a-zA-Z0-9]{7,12}$/);
  
  isExistReg();

  if ($('.ad').length > 0) { 
    $('.ad').remove();
  } else {
    console.log("element has been removed");
  }

  function isExistReg(){
    for(i=0;i<50;i++){
      var tempStr = $("div").eq(i).attr("id");
      if(typeof(tempStr)=="undefined"){
        continue;    
      } else {
        if(reg.test(tempStr)){
          //console.log(tempStr);          
          $("#"+tempStr).remove();          
        }else{
          //console.log("BUG");
        }    
      }
    }
  } 
};