Greasy Fork is available in English.
元初芸提供标准化的零售行业标准SAAS,为您便捷、快速地完成微信相关公众号、小程序的快速部署!! https://console.tebieshuang.xyz
当前为
// ==UserScript==
// @name 抓取公众号文章里面视频
// @namespace https://console.tebieshuang.xyz
// @supportURL https://console.tebieshuang.xyz
// @version 2.0.0
// @description 元初芸提供标准化的零售行业标准SAAS,为您便捷、快速地完成微信相关公众号、小程序的快速部署!! https://console.tebieshuang.xyz
// @author Leo
// @include *://mp.weixin.qq.com/s/*
// @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 );
}
function getVideo( vid ){
var s = document.createElement("script"), callback = "jsonpCallback_" + new Date().getTime(), url = "http://vv.video.qq.com/getinfo?vids="+vid+"&platform=101001&charge=0&otype=json&callback=" + callback;
window[callback] = function (data) {
let video = data['vl']['vi'][0];
let media= 'https://ugcws.video.gtimg.com/' + video['fn'] + '?vkey=' + video['fvkey'], image = 'https://puui.qpic.cn/qqvideo_ori/0/' + vid + '_496_280/0', title = video["ti"];
showDetail( title, media, image );
};
s.src = url;
document.body.appendChild(s);
}
setTimeout( function(){
let ifs = document.querySelectorAll('iframe.video_iframe'), vds = document.querySelectorAll('.js_inner video'), ss = document.querySelector('#js_mpvedio iframe');
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 );
}else if( ss != null ){
let videoUrl = ss.getAttribute('src'), videoInfo = videoUrl.split("&vid=")[1].split("&")[0];
getVideo(videoInfo);
}
setTimeout( function(){
document.querySelector('#closeVideoMask').addEventListener('click', function(){
closeMask();
}, false);
}, 1000 );
}, 2000 );
})();