// ==UserScript== // @name 抓取公众号文章里面视频 // @namespace https://console.tebieshuang.xyz // @version 1.0 // @description 元初芸 // @author Leo // @include *://mp.weixin.qq.com/s/* // @include *://mp.weixin.qq.com/s?* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; function closeMask(){ let el = document.querySelector( '#video-data-src-mask' ); el.parentNode.removeChild( el ); } function showDetail( title, media, image ){ let html = '
', e = document.createElement('div'); e.innerHTML = html; document.body.appendChild( e ); } setTimeout( function(){ let ifs = document.querySelectorAll('iframe.video_iframe'), vds = document.querySelectorAll('.js_inner video'); if( ifs.length > 0 ){ let title = document.querySelectorAll('meta[property="og:title"]')[0].getAttribute('content'), domDocument = ifs[0].contentDocument, thumb = domDocument.querySelectorAll('.poster_cover')[0].style.backgroundImage, media = domDocument.querySelectorAll('video')[0].getAttribute('origin_src'), image = thumb.substring(5, thumb.length-2); showDetail( title, media, image ); }else if( vds.length > 0 ){ let title = document.querySelectorAll('meta[property="og:title"]')[0].getAttribute('content'), thumb = document.querySelectorAll('.js_poster_cover')[0].style.backgroundImage, media = vds[0].getAttribute('origin_src'), image = thumb.substring(5, thumb.length-2); showDetail( title, media, image ); } setTimeout( function(){ document.querySelector('#closeVideoMask').addEventListener('click', function(){ closeMask(); }, false); }, 1000 ); }, 2000 ); })();