init
This commit is contained in:
lico
2022-04-09 01:20:08 +08:00
commit c0400cccba
18 changed files with 326725 additions and 0 deletions

335
mod/GeneralBlock.txt Normal file
View File

@ -0,0 +1,335 @@
! Fix for MS Edge
tieba.baidu.com###pagelet_entertainment-liveshow\/pagelet\/video_head
! Start
500px.com###hellobar
bing.com###banner
coding.net##.smart-app-banner
coolapk.com##[style*="position: fixed;bottom: 0"]
engadget.com###ldrBoardAd
gelbooru.com##A[href*="ads="]
github.com##.js-notice
jav777.cc###divExoLayerWrapper
mp.weixin.qq.com###js_pc_qr_code
m.chouti.com##.m_download_box
m.jd.com##.download-pannel
m.jiemian.com###js-b-ad
m.qidian.com###fixBoxs, #read_app_download
news.sina.com.cn##.news_weixin_ercode
yahoo.com###my-adsFPL
yahoo.com##.js-stream-featured-ad
vdisk.weibo.com###ads_layer
weibo.cn##.tips.m-container-max
www.1069gay.net###shortcut
www.15yan.com##.tooltip
www.52tian.net##.adwidewrap
www.acfun.cn###guide-fix
www.douyu.com##.giftbatter-box
www.dwnews.com##.big2-gg
www.freehao123.com##A[href*="/go/"]
www.google.com##.ads-ad
www.hardsextube.com##.right-col.right
www.le.com###full_Column_big
www.le.com###full_Column_small
www.le.com###rightBottomPop
www.lofter.com###appdownloadbanner
www.raybt.com##td[width="13"]
www.yizhibo.com##.register_guide
tumblr.com##.standalone-ad-container
twitter.com##.presented
www.xilinjie.com###xlj-da-block-overlay
xhamster.com##.sponsorBottom
.com/c.gif?
.cn/a.gif?
.cn/b.gif?
.cn/r.gif?
.cn/s.gif?
.cn/z.gif?
.com/pv.gif?
.hk/ad2/
.hk/groupon/ads/
://ads2.
/atrk.js
/googlead.js
/popunder.js
/popunder2.js
/videojs5/*vpaid.min.js$domain=91porn.com|email.91dizhi.at.gmail.com.8h9.space
/fans/*$domain=91porn.com|email.91dizhi.at.gmail.com.8h9.space
/openload.co$third-party,domain=openload.co|oload.tv
|http://*/source/plugin/u179_jtft/
|https:$popup,domain=openload.co|oload.tv|javno.me
|http:$popup,domain=openload.co|oload.tv
|http:$script,domain=imagebam.com|imagevenue.com|playvid.com|4horlover.com
|http:$subdocument,domain=imagebam.com|playvid.com
|http:$third-party,domain=linkshrink.net
|https:$third-party,domain=linkshrink.net
@@||apis.google.com^$domain=openload.co|oload.tv|javno.me|imagebam.com|imagevenue.com|playvid.com|4horlover.com|linkshrink.net
@@||cdn.bootcss.com^$domain=openload.co|oload.tv|javno.me|imagebam.com|imagevenue.com|playvid.com|4horlover.com|linkshrink.net
@@||googleapis.com^$domain=openload.co|oload.tv|javno.me|imagebam.com|imagevenue.com|playvid.com|4horlover.com|linkshrink.net
!@@||googletagmanager.com/gtm.js$domain=www.nintendo.co.jp
@@/js/ads.$domain=shrinklink.co
||115.com/static/plug/video_play/qrcode.js
||ad.directrev.com^$popup
||ad.mail.ru^
||adadvisor.net^
||addtoany.com/menu/transparent.gif
||adk2x.com^$third-party
||admaster.com.cn^$third-party
||ads.yahoo.com^
||adsfactor.net^
||adskeeper.co.uk^
||adstract.com^$third-party
||adxxx.$third-party
||adrunnr.com^
||adzerk.net^
||aidigua.com^
||amung.us^
||api.kodcloud.com/data/notify/
||an.yandex.ru^
||analytics.163.com^
||ancplayer.com/ancplayer/ads
||atemda.com^$third-party
||awempire.com^$third-party
||baifendian.com^$third-party
||blogamethu.com^
||bthand.com/static/js/default.js
||buysellads.com^$third-party
||cache.netease.com/cnews/js/qrcode.js
||cache1.value-domain.com/xrea_header.js
@@||cdndx.clouddata8g.xyz^$domain=ohmanhua.com
||changyan.itc.cn/mdevp/extensions/mobile-cmt-advert/
||clicksor.net^$third-party
||comgnnyx.com^
||cmsjs.eastmoney.com/js/news_*.js
||creative.xtendmedia.com^
||criteo.com^$third-party
||criteo.net^$third-party
||da-ads.com^$third-party
||directtrk.com/js/pop.js$third-party
||discuss.com.hk/include/javascript/idle_check.js
||discuss.com.hk/overture/
||doubleclick.net/instream/ad_status.js
||dwnews.com/RealMedia/ads/
||dwnews.net/images/www/ad/
||dwnews.net/js/common/dwnews.dwcn.ad.js
||dwnews.net/js/common/dwnews.ga.js
||elcncc.com^$third-party
||ero-advertising.com^
||etahub.com^$third-party
||exoticads.com^$third-party
||feih.com.cn^$third-party
||flashi.tv/histats.php?
||forum.xitek.com/xml/flash.swf
||gelbooru.com/script/application.js
||genieessp.com^$third-party
||greencompute.org^$third-party
||guardwork.info^$third-party
||hb.vntsm.com/v3/live/ad-manager.min.js
||histats.com^$third-party
||insightexpressai.com^
||jav777.cc/wp-content/themes/baskerville/js/jquery-ui
||js.fhxiaoshuo.com^
||juiceads.net^
||juicyads.com^
||live800.com^$domain=licai.com
||m.addthis.com/live/red_lojson/300lo.json
||m.paipai.fm/js/jquery.slides.min.js
||mobfox.com/ad_sdk.js
||moatads.com^
||media.pussycash.com^$third-party
||member.jschina.com.cn/AD
||okmuxdbq.com^
||onclickpredictiv.com^
||onclickads.net^
||oload.tv/assets/js/script.packed
||openload.co/assets/js/script.packed
||optimix.asia^
||optimizely.com^$third-party
||networld.hk^$third-party
||nibblebit.com/assets/media/adverts.php
||padstm.com^$third-party
||projectwonderful.com$third-party
||popads.net^$third-party
||popcash.net^$third-party
||popmyads.com^$third-party
||prf.hn^$third-party
||prscripts.com^$third-party
||prpops.com^$third-party
||qiniucdn.com^$domain=enrz.com,image
||revcontent.com^$third-party
||serving-sys.com^
||sexad.net^$third-party
||ssl.trace.zhiziyun.com^
||statcounter.com/counter/counter.js
||stats.hosting24.com/count.php
||static.creatives.livejasmin.com/adcreative2/
||static.xvideos.com/js/jquery.popunder.js
||strdef.world/js/acheck.js
||syndication.jsadapi.com^$third-party
||tianqi.com/img/wx2211.js
||tkres.tuku.cc/k32/
||trace.qq.com^
||traffichaus.com^
||trafficjunky.net^
||trafficfactory.biz^
||trafficstars.com^
||tribalfusion.com^
||trw12.com^$third-party
||uuxs.net^$subdocument
||videowood.tv/assets/js/popup.js
||videowood.tv/pop^$popup
||videowood.tv/pop2
||watchmygf.to^$third-party
||www.blnovel.com/cmjs/$script
||www.blnovel.com/e/$script
||www.blnovel.com/qrcode.php
||www.gelbooru.com/thumbnails/
||www.pcbeta.com//data/cache/ggk.js
||xiamp4.com/tj.js
||xiucm.com^$third-party
||xemphimviet.net^$third-party
||xxxnavy.com^$third-party
||xtube.com/js/ht.js
||xtube.com/theme/v2/vendor/js-popunder/
||yllix.com^
||yahoo.com^*banner_ad
||yimg.com/*/ads/
||yimg.com/av/gemini/ga/gemini.js
||yimg.com/rq/darla/
||yimg.com/uq/syndication/yad.js
||yimg.com/zz/combo?cv
||zhongxinghuanyu.com^$third-party
||zedo.com^$third-party
||zencdn.net^$domain=freegaypornsex.net|www.gayvl.info
! 2345
@@||union2.50bang.org^$third-party
! 6park
!|http:$third-party,image,domain=www.6park.com
!|https:$third-party,image,domain=www.6park.com
@@||popo8.com^$domain=www.6park.com
! BiliBili
live.bilibili.com##.bilibili-live-player-video-gift
live.bilibili.com##.fans-medal-item-ctnr
live.bilibili.com##.chat-item.gift-item
live.bilibili.com##.chat-item.welcome-guard
live.bilibili.com##.chat-item.welcome-msg
live.bilibili.com##.guard-icon
live.bilibili.com##.live-haruna-ctnr
live.bilibili.com##.m-guard-ent
live.bilibili.com##.outlink
live.bilibili.com##.penury-gift-msg
live.bilibili.com##.system-msg.news
live.bilibili.com##.title-label
live.bilibili.com##.user-level-icon
live.bilibili.com##.vip-icon
||api.live.bilibili.com/live_user/v1/Wish
! Cam4
||cam4.com/ads/
||cam4.com/buygift/
||cam4.com/directoryFanClubs?
*/web/js/th/$domain=cam4.com
cam4.com###Cam4DialogContainer
cam4.com###disclaimerModal
cam4.com###goldNavbar
cam4.com###subfoot
cam4.com###tippingCulture
cam4.com##.hbanner
cam4.com##.promo-center
cam4.com##.sponsorAd
cam4.com##.stickyAd
cam4.com##.xmlAdsTitle
cam4.com##.xmlAdsWrapper
! Chaturbate
||chaturbate.com/affiliates/
||nsimg.net^
chaturbate.com##IMG[rel="nofollow"]
chaturbate.com##.ad
chaturbate.com##.banner
! 中华网闲置2分钟广告
junshi.china.com###mod-box
junshi.china.com##.w_xiao>.side_bdgg
toutiao.china.com###js-free-time-show
! COCOmanhua
@@||cdndx.clouddata8g.xyz^$script,domain=www.cocomanhua.com
! 低端影视
||ddrk.me/vjs-plugins/videojs.das.min.js
!通用去除dplayer播放器logo https://bbs.kafan.cn/forum.php?mod=redirect&goto=findpost&ptid=2180923&pid=46929896
##.dplayer-logo
###sponsorAdDiv
###sponsorAdCountdown
###adleft
###adright
nfmovies.com##[src*="/pic/tu/"]
nfmovies.com##[src*="/static/"]
||nfmovies.com/templets/default/images/js/layer/layer.js
nfmovies.com###aaaDiv
nfmovies.com###zzzif
nfmovies.com###zzzif2
nfmovies.com###aaaCountdown
nfmovies.com###aaaDiv2
nfmovies.com##.fa fa-volume-down
nfmovies.com##.close-box.tips
nfmovies.com##.hidden-xs.dropdown-hover
nfmovies.com##li.dropdown-hover:nth-of-type(9)
nfmovies.com##.myui-player__operate > li:nth-of-type(1)
nfmovies.com##.myui-player__operate > li:nth-of-type(4)
nfmovies.com##.myui-player__operate > li:nth-of-type(5)
nfmovies.com##+js(nano-sib)
nfmovies.com##+js(nostif, container)
nfmovies.com##body:style(opacity:1!important)
nfmovies.com##body > div.hidden-xs
@@||www.nfmovies.com/static/side.jpg
@@||www.nfmovies.com/pic/tu/banner-03.jpg
@@||www.nfmovies.com/pic/tu/banner03.jpg
! Facebook
www.facebook.com###pagelet_side_ads
www.facebook.com##.egoOrganicColumn+*
! ithome
ithome.com###a_ad
www.ithome.com###lapin
www.ithome.com##.content>a[href="http://m.ithome.com/ithome/"]
||img.ithome.com/file/js/wap/apprecommend.js
! Letv
|http://*/letv-gug/
||banana.le.com/letv_tracker.js$domain=m.le.com
||dc.letv.com/op/?
||player.letvcdn.com/*/newplayer/1/WatchingBuy.swf
! leisu
@@||tracker.namitiyu.com^
! mgtv
m.mgtv.com##.mg-dcross
www.mgtv.com##.m-headgg
! mydrivers
www.mydrivers.com###weixin_box
! OutLook
||res.office365.com/*/scripts/owa.AdsPanel.js
||res.office365.com/*/scripts/microsoft.owa.adsbar.js
||outlook.live.com/*/scripts/microsoft.owa.adsbar.js
! Paper
www.thepaper.cn##.pdtt01
m.thepaper.cn##.toutiao
m.thepaper.cn##.bot_banner
! PornHub
pornhub.com###hd-rightColVideoPage>none
pornhub.com##.videos-morepad.videos.full-row-thumbs.videos-being-watched.logInHotContainer+*
pornhub.com##.inesuch
pornhub.com##.hd.clear
||doublepimpssl.com^$third-party
||phncdn.com/html5shiv-*.js
||phncdn.com/www-static/js/widgets-live-popup.js
||phncdn.com/www-static/js/ph-tracking.js
||phncdn.com/www-static/js/promo-banner.js
! QQVideo
!||ca.gtimg.com/adplugin/swf/MediaPlugin.swf
! Youtube
youtube.com###contents>ytd-search-pyv-renderer
youtube.com##+js(json-prune, playerResponse.adPlacements playerResponse.playerAds adPlacements playerAds)
youtube.com###video-masthead
youtube.com###masthead-ad
m.youtube.com###koya_child_6
!m.youtube.com##._menb>._mab:nth-child(1)
||youtube.com/*=adunit&
||youtube.com/*&yt_ad
||youtube.com/get_midroll_info?
! Baidu
^monitor.jpg?xcode^
pan.baidu.com##.upload-bar.global-clearfix

112
mod/TiebaBlock.txt Normal file
View File

@ -0,0 +1,112 @@
! Images & Scripts
*/widget/spage_game_tab/$domain=tieba.baidu.com
||xiu8.com/live/$domain=tieba.baidu.com
||share.baidu.com/static/js/
||tieba.baidu.com/app/pop/bws/popup
||tieba.baidu.com/tbapp/user/getRecommendApp
||static.tieba.baidu.com/tb/pms/
||static.tieba.baidu.com/tb/img/pv.gif
||static.tieba.baidu.com/tb/img/track.gif
||bdstatic.com/r/www/*cache/baidu_search/
||bdstatic.com/tb/_/qrcode_*.js
||bdstatic.com/tb/_/umoney_*.js
||bdstatic.com/tb/cms/post/bubble/
||bdstatic.com/tb/img/firework_
||bdstatic.com/tb/static-common/js/pic_share/logger.js
||bdstatic.com/tb/static-pb/img/voice_ad.gif
! iTieba & Homepage
jump.bdimg.com,tieba.baidu.com###adide_platform
jump.bdimg.com,tieba.baidu.com###media_item
jump.bdimg.com,tieba.baidu.com###spage_game_tab_wrapper
jump.bdimg.com,tieba.baidu.com###spage_liveshow_slide
jump.bdimg.com,tieba.baidu.com###plat_act_wrapper
jump.bdimg.com,tieba.baidu.com##.ihome_aside_section[j-mygift]
jump.bdimg.com,tieba.baidu.com##.ihome_game_group
jump.bdimg.com,tieba.baidu.com##.member_rank
jump.bdimg.com,tieba.baidu.com##.userinfo_scores
! Top Right
jump.bdimg.com,tieba.baidu.com##.fMember_cnt
jump.bdimg.com,tieba.baidu.com##.split
jump.bdimg.com,tieba.baidu.com##.u_app
jump.bdimg.com,tieba.baidu.com##.u_appcenterEntrance
!jump.bdimg.com,tieba.baidu.com##.u_bdhome
jump.bdimg.com,tieba.baidu.com##.u_blue
jump.bdimg.com,tieba.baidu.com##.u_game
jump.bdimg.com,tieba.baidu.com##.u_grab_treasure
jump.bdimg.com,tieba.baidu.com##.u_joinvip
jump.bdimg.com,tieba.baidu.com##.u_split
!jump.bdimg.com,tieba.baidu.com##.u_member
jump.bdimg.com,tieba.baidu.com##.u_menu_tbmall
jump.bdimg.com,tieba.baidu.com##.u_mytbmall
jump.bdimg.com,tieba.baidu.com##.u_xiu8
jump.bdimg.com,tieba.baidu.com##.u_wallet
! Top
jump.bdimg.com,tieba.baidu.com###local_board
jump.bdimg.com,tieba.baidu.com###j_navtab_wanle
jump.bdimg.com,tieba.baidu.com###j_navtab_game
jump.bdimg.com,tieba.baidu.com##.gift-goin
jump.bdimg.com,tieba.baidu.com##.icon_group
jump.bdimg.com,tieba.baidu.com##.j_tbnav_tab_a[stats-data^="fr=tb0_forum&st_mod=frs&st_value=tabgroup"]
jump.bdimg.com,tieba.baidu.com##.star_nav_ico_activity
jump.bdimg.com,tieba.baidu.com##.star_nav_ico_deal
jump.bdimg.com,tieba.baidu.com##.star_nav_ico_group
jump.bdimg.com,tieba.baidu.com##.star_nav_ico_tuan
! Sides
jump.bdimg.com,tieba.baidu.com###aside_ad
jump.bdimg.com,tieba.baidu.com###aside_ad_wrapper
jump.bdimg.com,tieba.baidu.com###novel-ranking
jump.bdimg.com,tieba.baidu.com###tieba-notice.region_bright
jump.bdimg.com,tieba.baidu.com##.app_download_box
jump.bdimg.com,tieba.baidu.com##.app_forum_rank_float
jump.bdimg.com,tieba.baidu.com##.aside_region.celebrity
jump.bdimg.com,tieba.baidu.com##.fansparty-wrap
jump.bdimg.com,tieba.baidu.com##.guess-sidebar-container
jump.bdimg.com,tieba.baidu.com##.nani_app_download_box
jump.bdimg.com,tieba.baidu.com##.platform_aside_tieba_partner
jump.bdimg.com,tieba.baidu.com##.profile_bottom
jump.bdimg.com,tieba.baidu.com##.region_bright.celebrity
jump.bdimg.com,tieba.baidu.com##.tbui_fbar_bazhu
jump.bdimg.com,tieba.baidu.com##.tbui_fbar_props
jump.bdimg.com,tieba.baidu.com##.tieba_notice
jump.bdimg.com,tieba.baidu.com##.user_score
! Central
jump.bdimg.com,tieba.baidu.com###top_activity
jump.bdimg.com,tieba.baidu.com##.achievement_medal_wrapper
jump.bdimg.com,tieba.baidu.com##.card_userinfo_honor
jump.bdimg.com,tieba.baidu.com##.d_icons
jump.bdimg.com,tieba.baidu.com##.d_nameplate
jump.bdimg.com,tieba.baidu.com##.dialogJ.game_player_auth_dialog
jump.bdimg.com,tieba.baidu.com##.dialogJ.tieba-sign-card
jump.bdimg.com,tieba.baidu.com##.fav-wrapper
jump.bdimg.com,tieba.baidu.com##.icon_author
jump.bdimg.com,tieba.baidu.com##.icon_wrap
jump.bdimg.com,tieba.baidu.com##.icon_replyer
jump.bdimg.com,tieba.baidu.com##.icon_tbworld
jump.bdimg.com,tieba.baidu.com##.j-post-send-gift
jump.bdimg.com,tieba.baidu.com##.p_mall_tail
jump.bdimg.com,tieba.baidu.com##.pre_icon_wrap
jump.bdimg.com,tieba.baidu.com##.save_face_bg
jump.bdimg.com,tieba.baidu.com##.sofa_front_list_wrap
jump.bdimg.com,tieba.baidu.com##.share_btn_wrapper
jump.bdimg.com,tieba.baidu.com##.thread_recommend_ps
jump.bdimg.com,tieba.baidu.com##.user_card_vip_tips
! Bottom
jump.bdimg.com,tieba.baidu.com###bdshare
jump.bdimg.com,tieba.baidu.com###guide_fc
jump.bdimg.com,tieba.baidu.com###xiu8_follow_warn
jump.bdimg.com,tieba.baidu.com##.add_guessing_btn
jump.bdimg.com,tieba.baidu.com##.edui-btn-medal
jump.bdimg.com,tieba.baidu.com##.edui-btn-paypost
jump.bdimg.com,tieba.baidu.com##.j_surveillance
jump.bdimg.com,tieba.baidu.com##.showBar
! Mobile
||tieba.baidu.com/mo/q/appSpecialThread
tieba.baidu.com##.client_ghost_icon
tieba.baidu.com##.daoliu_sign_in_show
tieba.baidu.com##.dia_mask
tieba.baidu.com##.dia_wrapper
tieba.baidu.com##.forum_recommend_w
tieba.baidu.com##.light_top_ext_area
tieba.baidu.com##.j_click_stats, .j_click_stats+*
tieba.baidu.com##.more_btn_package
tieba.baidu.com##.tuijian-wrap

10
mod/ad-edentw-title.txt Normal file
View File

@ -0,0 +1,10 @@
[Adblock Plus 2.0]
! Title: edentwCustom
! Expires: 12 hours
! Version: 201412030951
! Last Modified: 201412030952
! Homepage: https://adf.minggo.eu.org
! 本规则合并自Adblock Warning Removal List、ABP filters、anti-adblock-killer-filters感谢各位大大的分享
! 仅合并规则,未做其余任何处理
! 如有任何疑问、意见或建议请反馈至HalfLife吧
!

10
mod/ad-mo-title.txt Normal file
View File

@ -0,0 +1,10 @@
[Adblock Plus 2.0]
! Title: My AdFiltersfor Mobile
! Expires: 12 hours
! Version: 201412030951
! Last Modified: 201412030952
! Homepage: https://adf.minggo.eu.org
! 本规则合并自Easylist、EasylistChina、EasyPrivacy、CJX'sAnnoyance
! 感谢各位前辈的分享!
! 如有任何疑问、意见或建议请反馈至HalfLife吧
!

10
mod/ad-pc-title.txt Normal file
View File

@ -0,0 +1,10 @@
[Adblock Plus 2.0]
! Title: My AdFiltersfor PC
! Expires: 12 hours
! Version: 201412030951
! Last Modified: 201412030952
! Homepage: https://adf.minggo.eu.org
! 本规则合并自乘风视频广告过滤规则、Easylist、EasylistChina、EasyPrivacy、CJX'sAnnoyance
! 并补充了贴吧过滤规则,感谢各位前辈的分享!
! 如有任何疑问、意见或建议请反馈至HalfLife吧
!

10
mod/ad-title.txt Normal file
View File

@ -0,0 +1,10 @@
[Adblock Plus 2.0]
! Title: My AdFilters
! Expires: 12 hours
! Version: 201412030951
! Last Modified: 201412030952
! Homepage: https://adf.minggo.eu.org
! 本规则合并自乘风视频广告过滤规则、EasylistChina、EasylistLite、CJX'sAnnoyance
! 并补充了贴吧过滤规则,感谢各位前辈的分享!
! 如有任何疑问、意见或建议请反馈至HalfLife吧
!

10
mod/ad2-title.txt Normal file
View File

@ -0,0 +1,10 @@
[Adblock Plus 2.0]
! Title: CJX's AdFilters
! Expires: 12 hours
! Version: 201412030951
! Last Modified: 201412030952
! Homepage: https://adf.minggo.eu.org
! 本规则合并自乘风视频广告过滤规则、EasylistChina、EasylistLite、CJX'sAnnoyance
! 仅合并规则,未做其余任何处理
! 如有任何疑问、意见或建议请反馈至HalfLife吧
!

10
mod/ad3-title.txt Normal file
View File

@ -0,0 +1,10 @@
[Adblock Plus 2.0]
! Title: AdFilters
! Expires: 12 hours
! Version: 201412030951
! Last Modified: 201412030952
! Homepage: https://adf.minggo.eu.org
! 本规则合并自乘风视频广告过滤规则、EasylistChina、EasylistLite、CJX'sAnnoyance、EasyPrivacy感谢各位大大的分享
! 仅合并规则,未做其余任何处理
! 如有任何疑问、意见或建议请反馈至HalfLife吧
!

83
mod/addChecksum.pl Normal file
View File

@ -0,0 +1,83 @@
#!/usr/bin/perl
#############################################################################
# To add a checksum to a subscription file, run the script like this: #
# perl addChecksum.pl subscription.txt #
#############################################################################
use strict;
use warnings;
use Digest::MD5 qw(md5_base64);
die "Usage: $^X $0 subscription.txt\n" unless @ARGV;
#my $file = $ARGV[0];
foreach my $file (@ARGV) {
my $data = readFile($file);
# Get existing checksum.
$data =~ /^.*!\s*checksum[\s\-:]+([\w\+\/=]+).*\n/gmi;
my $oldchecksum = $1;
# Remove already existing checksum.
$data =~ s/^.*!\s*checksum[\s\-:]+([\w\+\/=]+).*\n//gmi;
# Calculate new checksum: remove all CR symbols and empty
# lines and get an MD5 checksum of the result (base64-encoded,
# without the trailing = characters).
my $checksumData = $data;
$checksumData =~ s/\r//g;
$checksumData =~ s/\n+/\n/g;
# Calculate new checksum
my $checksum = md5_base64($checksumData);
# If the old checksum matches the new one bail.
if ($checksum eq $oldchecksum)
{
$data = ();
next;
}
# Update the date.
my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
$year += 1900; # Year is years since 1900.
my $todaysdate = "$mday $months[$mon] $year";
$data =~ s/(^.*!.*Updated:\s*)(.*)\s*$/$1$todaysdate/gmi;
# Recalculate the checksum as we've altered the date.
$checksumData = $data;
$checksumData =~ s/\r//g;
$checksumData =~ s/\n+/\n/g;
$checksum = md5_base64($checksumData);
# Insert checksum into the file
$data =~ s/(\r?\n)/$1! Checksum: $checksum$1/;
writeFile($file, $data);
$data = ();
}
sub readFile
{
my $file = shift;
open(local *FILE, "<", $file) || die "Could not read file '$file'";
binmode(FILE);
local $/;
my $result = <FILE>;
close(FILE);
return $result;
}
sub writeFile
{
my ($file, $contents) = @_;
open(local *FILE, ">", $file) || die "Could not write file '$file'";
binmode(FILE);
print FILE $contents;
close(FILE);
}