Greasy Fork

Greasy Fork is available in English.

网易新闻视频地址解析

网易新闻内容 视频地址 解析

当前为 2021-11-02 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         网易新闻视频地址解析
// @namespace    http://fulicat.com
// @version      1.0.0
// @url           http://greasyfork.icu/zh-CN/scripts/382595
// @description  网易新闻内容 视频地址 解析
// @author       Jack.Chan
// @match        *://c.m.163.com/news/*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';
    var $player = document.querySelector('#player');
    if ($player && $player.src) {
        var url = $player.src, title = document.title;
        var style = [];
        style.push('<style type="text/css">');
        style.push('.parser{position:fixed;right:0;bottom:0;left:0px;z-index:99999;background-color:#fff;box-shadow: 0 -3px 10px 2px #ccc;}');
        style.push('.parser-list{max-width:750px;margin:0 auto;padding-bottom:10px;background-color:rgba(255,255,255,0.95);line-height:2em;overflow:hidden;}');
        style.push('.parser-list>dt{background-color:#eee;font-size:18px;padding:10px;}');
        style.push('.parser-list>dd{border-top:1px #ccc solid;padding:10px 10px;}');
        style.push('.parser-list a{color:#3d93ef;}');
        style.push('.parser-list a:hover{text-decoration:underline;}');
        style.push('.g-body-wrap{margin-top:0;}');
        style.push('.m-video-player{position:static;top:0;margin-left:0;}');
        style.push('</style>');

        var html = [];
        html.push('<dl class="parser-list">');
        html.push('<dt>视频:'+ title +'</dt>');
        html.push('<dd><a target="_blank" href="'+ url +'">'+ title +'</a>&nbsp;&nbsp;&nbsp;<a target="_blank" href="'+ url +'" download="'+ title +'">下载</a></dd>');
        html.push('</dl>');

        var $parser = document.createElement('div');
        $parser.id = 'parser';
        $parser.className = 'parser';
        $parser.innerHTML = style.join('') + html.join('');
        document.body.appendChild($parser);

        setTimeout(function(){
            var $items = document.querySelectorAll('li.js-open-newsapp');
            $items && $items.forEach(function(item) {
                (function(li){
                    var nli = li.cloneNode(true);
                    nli.onclick = function(e) {
                        e.preventDefault();
                        e.stopPropagation();
                        var param = this.dataset.param;
                        if (param) {
                            location.href = '//c.m.163.com/news/v/'+ param +'.html';
                        }
                        return false;
                    }
                    li.parentNode.replaceChild(nli, li);
                })(item);
            });
        }, 1000);
    }

	try{
		document.querySelector('.g-top-slider').remove();
		document.querySelector('.js-slider').remove();
		document.querySelector('.doc-footer-wrapper').remove();
		document.querySelector('.m-slider-footer').remove();
	}catch(ex){}
})();