[115.com] Local Player

Play Videos Via Local Player

  1. // ==UserScript==
  2. // @name [115.com] Local Player
  3. // @version 2.0.2
  4. // @description Play Videos Via Local Player
  5. // @match https://115.com/*
  6. // @author sam
  7. // @run-at document-end
  8. // @grant none
  9. // @namespace 115.com
  10. // ==/UserScript==
  11. $(document).ready(function(){
  12.  
  13. changeWindow();//去除无用侧边栏
  14.  
  15. //仅在wangpan框架内执行
  16. var page_url = window.location.href.substr(0,25);
  17. if (page_url =='https://115.com/?ct=file&'){
  18. addPlayer();//添加播放按钮
  19. addMenu();//调整菜单
  20. };
  21. });
  22.  
  23. function addMenu(){
  24. document.querySelector("#js_top_panel_box > div:nth-child(7)").remove(); //移除上传按钮
  25. //
  26. //document.querySelector("#js_top_panel_box > div.right-tvf > a:nth-child(1)").remove(); //移除我的分享
  27.  
  28. //添加'链接任务'按钮
  29. //$('<a href="javascript:;" id="add_task" class="button btn-linear-blue illt-offline" menu="offline_task" is_bind="1"><span>链接任务</span></a>').prependTo(document.querySelector("#js_top_panel_box > div.right-tvf"));
  30. //自动粘贴
  31. //var btn = document.querySelector("#add_task");
  32. //btn.addEventListener("click", autoPaste());
  33. }
  34.  
  35. function autoPaste(){
  36.  
  37. }
  38.  
  39. function changeWindow(){
  40. if(window.location.href === "https://115.com/home/userhome"){
  41. window.location = "https://115.com/?mode=wangpan";
  42. }else{
  43. var item_list,item_obj,item_name;
  44. var ifr = $("iframe[style='position: absolute; top: 0px;']");
  45. $("div#js-main_mode").css("display","none");
  46. $("div.main-core").css("left","0");
  47. ifr.load(
  48. function(){
  49. setCss();
  50. addMarkButton();
  51. item_list = ifr.contents().find("body").find("div#js_data_list");
  52. item_list.mouseenter(
  53. function(){
  54. if($("div.exph-loader").css("display") === "none" && !(item_list.find("div#isload").length)){
  55. item_list.append("<div id='isload'></div>");
  56. itemEvent();
  57. }
  58. }
  59. );
  60. }
  61. );
  62. }
  63. }
  64.  
  65. function addPlayer(){
  66. //本地播放器打开
  67. var requests = [],
  68. CloudVideo = window.CloudVideo = {
  69. showPanel: function (code) {
  70. this.getFileUrl(code, function (url) {
  71. //var xurl = 'ygl://' + encodeURIComponent(url);
  72. var xurl = 'potplayer://' + url; //原生potplayer调用
  73. console.log(xurl);
  74. window.location.href = xurl;
  75. });
  76. },
  77. getFileUrl: function (pickcode, callback) {
  78. requests.push([pickcode, callback])
  79. }
  80. };
  81.  
  82. $('<iframe>').attr('src', 'https://webapi.115.com/bridge_2.0.html?namespace=CloudVideo&api=jQuery').attr("id", 'ciid').css({
  83. width: 0,
  84. height: 0,
  85. border: 0,
  86. padding: 0,
  87. margin: 0,
  88. position: 'absolute',
  89. top: '-99999px'
  90. }).one('load', function () {
  91. var urlCache = {};
  92. CloudVideo.getFileUrl = function (pickcode, callback) {
  93. if (urlCache[pickcode]) {
  94. setTimeout(callback, 0, urlCache[pickcode]);
  95. } else {
  96. /*
  97. window.frames["ciid"].contentWindow.jQuery.get('https://webapi.115.com/files/download?pickcode=' + pickcode, function (data) {
  98. callback(urlCache[pickcode] = data.file_url)
  99. }, 'json');
  100. */
  101. //请求m3u8,调用potplayer打开
  102. var xhr = new XMLHttpRequest();
  103. xhr.open("GET", 'https://115.com/api/video/m3u8/' + pickcode + '.m3u8', true); //未加时间戳
  104. xhr.onreadystatechange = function() {
  105. if (this.readyState == 4 && this.status == 200) {
  106. var text = this.responseText,
  107. text_array=text.split("\n");
  108. text_array.shift();
  109. text_array.pop();
  110. //console.log(text_array);
  111. var BANDWIDTH = [],FILE_URL = [];
  112. for(let index in text_array) {
  113. //console.log(index,text_array[index]);
  114. if(index%2 == 0){
  115. var patt = /BANDWIDTH=(\d*)?/;
  116. var bw = text_array[index].match(patt)[1];
  117. BANDWIDTH.push(Number(bw));
  118. } else{
  119. FILE_URL.push(text_array[index]);
  120. };
  121. };
  122. var bw_max_index = BANDWIDTH.indexOf(Math.max(...BANDWIDTH));
  123. //console.log(FILE_URL);
  124. callback(urlCache[pickcode] = FILE_URL[bw_max_index]);
  125. }
  126. };
  127. xhr.send();
  128. };
  129. };
  130. requests.forEach(function (e) {
  131. CloudVideo.getFileUrl(e[0], e[1])
  132. });
  133. requests = null;
  134. }).appendTo('html');
  135.  
  136. //添加播放按钮
  137. $(document).on('mouseenter', 'li[rel="item"][file_type="1"][file_mode="9"]:not([is_loaded_vbutton="1"])', function () {
  138. var par_element = $(this).attr('is_loaded_vbutton', '1'),
  139. pick_code = par_element.attr('pick_code');
  140. var menu = par_element.find('[class="file-opr"]');
  141. $('<a href="javascript:;" menu_btn="more"><i class="icon ifo-share"></i><span>via.PotPlayer</a>').on('click', function () {
  142. CloudVideo.showPanel(pick_code);
  143. console.log(pick_code);
  144. }).appendTo(menu);
  145. });
  146.  
  147.  
  148. }
  149.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址