🏠 Home 

学习通视频秒#

功能强大,没有之一,支持手机端,修复加载失败.


ติดตั้งสคริปต์นี้?
  1. // ==UserScript==
  2. // @name 学习通视频秒#
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.6
  5. // @description 功能强大,没有之一,支持手机端,修复加载失败.
  6. // @author 汐
  7. // @match *://*.chaoxing.com/knowledge/cards*
  8. // @icon https://www.google.com/s2/favicons?domain=chaoxing.com
  9. // @grant GM_xmlhttpRequest
  10. // ==/UserScript==
  11. (function() {
  12. 'use strict';
  13. var _this = window.top[0];
  14. function Sdk(menu){
  15. this.menu = menu;
  16. this.href = '';
  17. this.arg = {};
  18. this.videos = [];
  19. this.defaults = {};
  20. this.installHook();
  21. this.initData();
  22. }
  23. Sdk.prototype.f = function(w) {
  24. function q(v, A) {
  25. var z = (v & 65535) + (A & 65535);
  26. var w = (v >> 16) + (A >> 16) + (z >> 16);
  27. return (w << 16) | (z & 65535)
  28. }
  29. function p(v, w) {
  30. return (v << w) | (v >>> (32 - w))
  31. }
  32. function k(B, y, w, v, A, z) {
  33. return q(p(q(q(y, B), q(v, z)), A), w)
  34. }
  35. function a(y, w, C, B, v, A, z) {
  36. return k((w & C) | ((~w) & B), y, w, v, A, z)
  37. }
  38. function h(y, w, C, B, v, A, z) {
  39. return k((w & B) | (C & (~B)), y, w, v, A, z)
  40. }
  41. function n(y, w, C, B, v, A, z) {
  42. return k(w ^ C ^ B, y, w, v, A, z)
  43. }
  44. function t(y, w, C, B, v, A, z) {
  45. return k(C ^ (w | (~B)), y, w, v, A, z)
  46. }
  47. function c(G, B) {
  48. G[B >> 5] |= 128 << (B % 32);
  49. G[(((B + 64) >>> 9) << 4) + 14] = B;
  50. var y;
  51. var A;
  52. var z;
  53. var w;
  54. var v;
  55. var F = 1732584193;
  56. var E = -271733879;
  57. var D = -1732584194;
  58. var C = 271733878;
  59. for (y = 0; y < G.length; y += 16) {
  60. A = F;
  61. z = E;
  62. w = D;
  63. v = C;
  64. F = a(F, E, D, C, G[y], 7, -680876936);
  65. C = a(C, F, E, D, G[y + 1], 12, -389564586);
  66. D = a(D, C, F, E, G[y + 2], 17, 606105819);
  67. E = a(E, D, C, F, G[y + 3], 22, -1044525330);
  68. F = a(F, E, D, C, G[y + 4], 7, -176418897);
  69. C = a(C, F, E, D, G[y + 5], 12, 1200080426);
  70. D = a(D, C, F, E, G[y + 6], 17, -1473231341);
  71. E = a(E, D, C, F, G[y + 7], 22, -45705983);
  72. F = a(F, E, D, C, G[y + 8], 7, 1770035416);
  73. C = a(C, F, E, D, G[y + 9], 12, -1958414417);
  74. D = a(D, C, F, E, G[y + 10], 17, -42063);
  75. E = a(E, D, C, F, G[y + 11], 22, -1990404162);
  76. F = a(F, E, D, C, G[y + 12], 7, 1804603682);
  77. C = a(C, F, E, D, G[y + 13], 12, -40341101);
  78. D = a(D, C, F, E, G[y + 14], 17, -1502002290);
  79. E = a(E, D, C, F, G[y + 15], 22, 1236535329);
  80. F = h(F, E, D, C, G[y + 1], 5, -165796510);
  81. C = h(C, F, E, D, G[y + 6], 9, -1069501632);
  82. D = h(D, C, F, E, G[y + 11], 14, 643717713);
  83. E = h(E, D, C, F, G[y], 20, -373897302);
  84. F = h(F, E, D, C, G[y + 5], 5, -701558691);
  85. C = h(C, F, E, D, G[y + 10], 9, 38016083);
  86. D = h(D, C, F, E, G[y + 15], 14, -660478335);
  87. E = h(E, D, C, F, G[y + 4], 20, -405537848);
  88. F = h(F, E, D, C, G[y + 9], 5, 568446438);
  89. C = h(C, F, E, D, G[y + 14], 9, -1019803690);
  90. D = h(D, C, F, E, G[y + 3], 14, -187363961);
  91. E = h(E, D, C, F, G[y + 8], 20, 1163531501);
  92. F = h(F, E, D, C, G[y + 13], 5, -1444681467);
  93. C = h(C, F, E, D, G[y + 2], 9, -51403784);
  94. D = h(D, C, F, E, G[y + 7], 14, 1735328473);
  95. E = h(E, D, C, F, G[y + 12], 20, -1926607734);
  96. F = n(F, E, D, C, G[y + 5], 4, -378558);
  97. C = n(C, F, E, D, G[y + 8], 11, -2022574463);
  98. D = n(D, C, F, E, G[y + 11], 16, 1839030562);
  99. E = n(E, D, C, F, G[y + 14], 23, -35309556);
  100. F = n(F, E, D, C, G[y + 1], 4, -1530992060);
  101. C = n(C, F, E, D, G[y + 4], 11, 1272893353);
  102. D = n(D, C, F, E, G[y + 7], 16, -155497632);
  103. E = n(E, D, C, F, G[y + 10], 23, -1094730640);
  104. F = n(F, E, D, C, G[y + 13], 4, 681279174);
  105. C = n(C, F, E, D, G[y], 11, -358537222);
  106. D = n(D, C, F, E, G[y + 3], 16, -722521979);
  107. E = n(E, D, C, F, G[y + 6], 23, 76029189);
  108. F = n(F, E, D, C, G[y + 9], 4, -640364487);
  109. C = n(C, F, E, D, G[y + 12], 11, -421815835);
  110. D = n(D, C, F, E, G[y + 15], 16, 530742520);
  111. E = n(E, D, C, F, G[y + 2], 23, -995338651);
  112. F = t(F, E, D, C, G[y], 6, -198630844);
  113. C = t(C, F, E, D, G[y + 7], 10, 1126891415);
  114. D = t(D, C, F, E, G[y + 14], 15, -1416354905);
  115. E = t(E, D, C, F, G[y + 5], 21, -57434055);
  116. F = t(F, E, D, C, G[y + 12], 6, 1700485571);
  117. C = t(C, F, E, D, G[y + 3], 10, -1894986606);
  118. D = t(D, C, F, E, G[y + 10], 15, -1051523);
  119. E = t(E, D, C, F, G[y + 1], 21, -2054922799);
  120. F = t(F, E, D, C, G[y + 8], 6, 1873313359);
  121. C = t(C, F, E, D, G[y + 15], 10, -30611744);
  122. D = t(D, C, F, E, G[y + 6], 15, -1560198380);
  123. E = t(E, D, C, F, G[y + 13], 21, 1309151649);
  124. F = t(F, E, D, C, G[y + 4], 6, -145523070);
  125. C = t(C, F, E, D, G[y + 11], 10, -1120210379);
  126. D = t(D, C, F, E, G[y + 2], 15, 718787259);
  127. E = t(E, D, C, F, G[y + 9], 21, -343485551);
  128. F = q(F, A);
  129. E = q(E, z);
  130. D = q(D, w);
  131. C = q(C, v)
  132. }
  133. return [F, E, D, C]
  134. }
  135. function o(w) {
  136. var x;
  137. var v = "";
  138. var y = w.length * 32;
  139. for (x = 0; x < y; x += 8) {
  140. v += String.fromCharCode((w[x >> 5] >>> (x % 32)) & 255)
  141. }
  142. return v
  143. }
  144. function j(w) {
  145. var y;
  146. var v = [];
  147. v[(w.length >> 2) - 1] = undefined;
  148. for (y = 0; y < v.length; y += 1) {
  149. v[y] = 0
  150. }
  151. var x = w.length * 8;
  152. for (y = 0; y < x; y += 8) {
  153. v[y >> 5] |= (w.charCodeAt(y / 8) & 255) << (y % 32)
  154. }
  155. return v
  156. }
  157. function i(v) {
  158. return o(c(j(v), v.length * 8))
  159. }
  160. function u(x, A) {
  161. var w;
  162. var z = j(x);
  163. var v = [];
  164. var y = [];
  165. var B;
  166. v[15] = y[15] = undefined;
  167. if (z.length > 16) {
  168. z = c(z, x.length * 8)
  169. }
  170. for (w = 0; w < 16; w += 1) {
  171. v[w] = z[w] ^ 909522486;
  172. y[w] = z[w] ^ 1549556828
  173. }
  174. B = c(v.concat(j(A)), 512 + A.length * 8);
  175. return o(c(y.concat(B), 512 + 128))
  176. }
  177. function s(z) {
  178. var y = "0123456789abcdef";
  179. var w = "";
  180. var v;
  181. var A;
  182. for (A = 0; A < z.length; A += 1) {
  183. v = z.charCodeAt(A);
  184. w += y.charAt((v >>> 4) & 15) + y.charAt(v & 15)
  185. }
  186. return w
  187. }
  188. function l(v) {
  189. return unescape(encodeURIComponent(v))
  190. }
  191. function e(v) {
  192. return i(l(v))
  193. }
  194. function m(v) {
  195. return s(e(v))
  196. }
  197. function b(v, w) {
  198. return u(l(v), l(w))
  199. }
  200. function r(v, w) {
  201. return s(b(v, w))
  202. }
  203. function f(w, x, v) {
  204. if (!x) {
  205. if (!v) {
  206. return m(w)
  207. }
  208. return e(w)
  209. }
  210. if (!v) {
  211. return r(x, w)
  212. }
  213. return b(x, w)
  214. }
  215. return f(w);
  216. };
  217. Sdk.prototype.queryElement = function(selector,source){
  218. return new Promise((resolve,rejcet)=>{
  219. let timer = setInterval(()=>{
  220. let _target = [];
  221. let body = ((source && source.contentDocument)?source.contentDocument:(source||document)).body
  222. if(body){ _target = body.querySelectorAll(selector); }
  223. if(_target.length>0) {
  224. clearInterval(timer);
  225. resolve(_target);
  226. }
  227. },100);
  228. });
  229. }
  230. Sdk.prototype.ajaxGet = function(url){
  231. return new Promise((resolve,rejcet)=>{
  232. GM_xmlhttpRequest({
  233. url:url,
  234. method:'get',
  235. headers: {"Content-Type": "application/json"},
  236. onload:function(response){
  237. resolve(JSON.parse(response.responseText));
  238. }
  239. });
  240. });
  241. }
  242. Sdk.prototype.installHook=function(){
  243. let observer = new MutationObserver((mutations)=>{
  244. let cells=[];
  245. for(let mutation of mutations){
  246. if(mutation.type == 'childList'){
  247. cells=[...mutation.addedNodes].filter(node=>{
  248. return node.className=='cells';
  249. });
  250. }
  251. }
  252. observer.disconnect();
  253. //console.log(cells);
  254. });
  255. observer.observe(_this.parent.coursetree, { childList: true });
  256. }
  257. Sdk.prototype.isVideo = function(attachment){
  258. return attachment.type == 'video';
  259. }
  260. Sdk.prototype.isVideoPass = function(attachment){
  261. return attachment.isPassed;
  262. }
  263. Sdk.prototype.playVideo = function(video){
  264. return video.videoEl.play();
  265. }
  266. Sdk.prototype.windowReload = function(){
  267. window.parent.location.reload();
  268. }
  269. Sdk.prototype.maskShow = function(){
  270. let menu = this.menu;
  271. let _targetEl = window.top.document.getElementById(menu.id);
  272. if(_targetEl){_targetEl.remove();}
  273. let div = document.createElement('div');
  274. div.id = menu.id;
  275. let title = (window.top.document.querySelector("#mainid > div.prev_title_pos > div") || window.top.document.querySelector("#mainid > h1")).innerText;
  276. let html = `<div id="menu" style="user-select:none;outline:ridge;padding:5px;z-index:99999;width:${menu.width}px;height:${menu.height}px;position:fixed;left:${menu.pos.x}px;top:${menu.pos.y}px;background:${menu.background};opacity:${menu.opacity};">`;
  277. let tmpHtml = `<h1 style="text-align:center;">${title}</h1><h2 style="text-align:center;font-size:10px;">By:汐</h2>`;
  278. tmpHtml += '数据获取中...';
  279. html += tmpHtml + `</div>`;
  280. div.innerHTML = html;
  281. window.top.document.body.append(div);
  282. }
  283. Sdk.prototype.maskHide = function(){
  284. // window.top[this.menu.id].remove();
  285. window.top[this.menu.id].innerHTML = '';
  286. }
  287. Sdk.prototype.getRurl = function(video,state = 0,playingTime=0){
  288. let format = "[{0}][{1}][{2}][{3}][{4}][{5}][{6}][{7}]",clipTime = (0 || "0") + "_" + (0 || window.parseInt(video.details.duration));
  289. let enc = _this.Ext.String.format(format,this.defaults.clazzId,this.defaults.userid,video.jobid || "",video.objectId,playingTime * 1000,"d_yHJ!$pdA~5",video.details.duration * 1000,clipTime);
  290. let isdrag = state; //0 4
  291. let t = new Date().getTime();
  292. if(state == 0){
  293. t -= window.parseInt(video.details.duration*1000);
  294. }
  295. return [this.defaults.reportUrl, "/", video.details.dtoken,"?clazzId=", this.defaults.clazzId,"&playingTime=", playingTime,"&duration=", video.details.duration,"&clipTime=", clipTime,"&objectId=", video.objectId,"&otherInfo=", video.otherInfo,"&jobid=", video.jobid,"&userid=", this.defaults.userid,"&isdrag=", isdrag,"&view=pc","&enc=", this.f(enc),"&rt=", 0.9,"&dtype=Video","&_t=", t].join("");
  296. }
  297. Sdk.prototype.getVideoEl = async function(attachment){
  298. for(let iframe of (await this.queryElement('iframe'))){
  299. let videoEl = (await this.queryElement('video',iframe))[0];
  300. if(videoEl){
  301. let http = await new Promise((resolve,rejcet)=>{
  302. let timer = setInterval(()=>{
  303. if(videoEl.src.length>0){
  304. clearInterval(timer);
  305. resolve(videoEl.src);
  306. }
  307. },100);
  308. });
  309. if(http == attachment.details.http) {return videoEl;}
  310. }
  311. }
  312. }
  313. Sdk.prototype.getVideoDetails = async function(attachment){
  314. return await this.ajaxGet('/ananas/status/'+attachment.objectId+'?k=' + this.defaults.fid+"&flag=normal");
  315. }
  316. Sdk.prototype.requestKillVideo = async function(rurl){
  317. return await this.ajaxGet(rurl);
  318. }
  319. Sdk.prototype.initData = async function(){
  320. try{
  321. this.maskShow();
  322. this.href = window.location.href;
  323. this.arg = _this.mArg;
  324. this.defaults = this.arg.defaults;
  325. this.videos.length = 0;
  326. for(let attachment of (this.arg.attachments)||[]){
  327. if(this.isVideo(attachment)){
  328. attachment.details = await this.getVideoDetails(attachment);
  329. //attachment.videoEl = await this.getVideoEl(attachment);
  330. this.videos.push(attachment);
  331. }
  332. }
  333. this.maskHide();
  334. this.initMenu();
  335. }catch(e){
  336. alert('错误:'+e.message+" 请将错误信息反馈给作者");
  337. }
  338. }
  339. Sdk.prototype.initMenu = function(){
  340. let menu = this.menu;
  341. let title = (window.top.document.querySelector("#mainid > div.prev_title_pos > div") || window.top.document.querySelector("#mainid > h1")).innerText;
  342. let html = `<div id="menu" style="user-select:none;outline:ridge;padding:5px;z-index:99999;width:${menu.width}px;height:${menu.height}px;position:fixed;left:${menu.pos.x}px;top:${menu.pos.y}px;background:${menu.background};opacity:${menu.opacity};">`;
  343. let tmpHtml = `<h1 style="text-align:center;">${title}</h1><h2 style="text-align:center;font-size:10px;">By:汐</h2>`;
  344. if(this.videos.length>0){
  345. this.videos.forEach((video,index)=>{
  346. tmpHtml += `<p style="height:21px;color:${video.isPassed?'green':'orange'};clear:both;margin:5px 0;background:${index%2?'#F5F5F5':'#D9EDF7'};"><span>${index+1}</span> -> <span>${video.property.name}</span> -> <button style="float:right;" onclick="window[0].sdk.killVideo(${index});">#死</button></p>`;
  347. });
  348. tmpHtml += `<div style="text-align:center;"><button onclick="window[0].sdk.killVideos();">章节通#</button></div>`;
  349. }else{tmpHtml += '此章节没有视频';}
  350. html += tmpHtml + `</div>`;
  351. window.top[this.menu.id].innerHTML = html;
  352. }
  353. Sdk.prototype.killVideos = async function(){
  354. let fail=0,total=0;
  355. for(let video of this.videos){
  356. if(video.isPassed){continue;}
  357. total++;
  358. if(!this.startKill(video)||!this.endKill(video)){
  359. fail++;continue;
  360. }
  361. }
  362. alert(`本次章节通#结束:总数[${this.videos.length}],任务[${total}],成功[${total-fail}],失败[${fail}]\n通#成功结果还是黄色,不用再次#死!!!`);
  363. this.windowReload();
  364. }
  365. Sdk.prototype.killVideo = async function(VideoIndex){
  366. let currentVideo = this.videos[VideoIndex];
  367. if(currentVideo.isPassed){return alert('兄弟,这个视频已经被#死了!');}
  368. if(!this.startKill(currentVideo)){
  369. return alert('初始化视频失败,请重试');
  370. }
  371. if(!this.endKill(currentVideo)){
  372. return alert('#死视频失败,请重试');
  373. }
  374. alert('成功#死视频,如刷新还是黄字,请等待一段时间查看.');
  375. this.windowReload();
  376. }
  377. Sdk.prototype.startKill = async function(video){
  378. return await this.requestKillVideo(this.getRurl(video,0,0));
  379. }
  380. Sdk.prototype.endKill = async function(video){
  381. return await this.requestKillVideo(this.getRurl(video,4,video.details.duration));
  382. }
  383. _this.sdk = new Sdk({
  384. id:"xidaren",
  385. background:'transparent',
  386. opacity:1,
  387. pos:{
  388. x:10,
  389. y:80
  390. }
  391. });
  392. })();