您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
try to take over the world!
当前为
// ==UserScript== // @name 抓取公众号文章里面视频 // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @include *://mp.weixin.qq.com/s/* // @grant 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 = '<div id="video-data-src-mask" style="display:flex;position:fixed;top:0;left:0;z-index:99999999;height:100vh;width:100vw;background:rgba(0,0,0,0.9);color:#fff;font-weight:bold;font-size:18px;"><div style="width:100%;height:100%;position:relative;"><div style="width:100%;height:100%;margin:auto;top:50px;left:0;right:0;bottom:0;position:absolute;"><div style="width:100%;text-align:center">标题:' + title + '</div><div style="width:100%;text-align:center">视频:<a style="color:#fff" href="' + media + '" target="_blank">点击查看</a></div><div style="width:100%;text-align:center">图片:<a style="color:#fff" href="' + image + '" target="_blank">点击查看</a></div><div style="width:100%;text-align:center;margin-top:100px;"><span id="closeVideoMask" style="color:#fff;" href="javascript:;">点击这里关闭</span></div></div></div></div>', 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 ); })();