// ==UserScript==
// @name 海角社区脚本
// @namespace haijiao-script
// @version 0.0.26
// @author memopac
// @description 海角社区视频解析
// @license MIT
// @icon https://pomf2.lain.la/f/erejxtfo.ico
// @match *://*.haijiao.com/*
// @match *://*/post/details*
// @require https://cdn.jsdelivr.net/npm/jquery@3.6.4
// @require https://cdn.jsdelivr.net/npm/dplayer@1.27.1
// @require https://cdn.jsdelivr.net/npm/hls.js@1.3.5
// @grant GM_setClipboard
// @grant GM_xmlhttpRequest
// ==/UserScript==
(e=>{const t=document.createElement("style");t.dataset.source="vite-plugin-monkey",t.textContent=e,document.head.append(t)})(` .crack_container{position:fixed;top:80px;right:20px}.crack_title{font-size:20px;font-weight:700;text-align:center;border:1px solid #000;cursor:pointer;display:block}.crack_player{position:fixed;top:0;bottom:0;left:0;right:0}.crack_player .iframeBox{width:70vw;margin:auto}
`);
(function (A, hls_js, p) {
'use strict';
var P=(()=>typeof GM_setClipboard<"u"?GM_setClipboard:void 0)(),_=(()=>typeof GM_xmlhttpRequest<"u"?GM_xmlhttpRequest:void 0)(),S="jsjiami.com.v7";const R=C;function C(s,d){const i=k();return C=function(t,e){t=t-236;let r=i[t];if(C.SPZMZv===void 0){var c=function(l){const m="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=";let x="",u="";for(let h=0,g,W,b=0;W=l.charAt(b++);~W&&(g=h%4?g*64+W:W,h++%4)?x+=String.fromCharCode(255&g>>(-2*h&6)):0)W=m.indexOf(W);for(let h=0,g=x.length;h<g;h++)u+="%"+("00"+x.charCodeAt(h).toString(16)).slice(-2);return decodeURIComponent(u)};const f=function(l,m){let x=[],u=0,h,g="";l=c(l);let W;for(W=0;W<256;W++)x[W]=W;for(W=0;W<256;W++)u=(u+x[W]+m.charCodeAt(W%m.length))%256,h=x[W],x[W]=x[u],x[u]=h;W=0,u=0;for(let b=0;b<l.length;b++)W=(W+1)%256,u=(u+x[W])%256,h=x[W],x[W]=x[u],x[u]=h,g+=String.fromCharCode(l.charCodeAt(b)^x[(x[W]+x[u])%256]);return g};C.wnoWFC=f,s=arguments,C.SPZMZv=!![];}const o=i[0],n=t+o,a=s[n];return a?r=a:(C.zdKWkW===void 0&&(C.zdKWkW=!![]),r=C.wnoWFC(r,e),s[n]=r),r},C(s,d)}function k(){const s=function(){return [S,"uhjFwsjiTSEamyi.UMcCwomXB.yIvBD7eRXFddKG==","dmkhDSooWOy","zmoBW4q+WQJcUGxdN14","W41xACokWPi/WOFdSCob","x8ogW5xcPCkz","W4ZdLSoQW5iSW4LOds4LW4XTWQVdMK7cMZK","FaldT8ocW5ZcJH4fjCkhuCk4WQ00","xW7cOCkzoq","ymoLWPj8mW","W6DRrSo0Fmo0WQBcVJtdVs/dTI1L","nJ0JWPju","WPxcICk3u8k1","WPVdI0qUWPxdNtzNna","W4RdVmoYW6et","v8kvW6tcP0G","W73cPmoRWOtdQa","WQdcO8kK","WPPSW7u5WP8","vCkuW4xcMNC"].concat(function(){return ["dc00uW","WPVdIebXW6NcIvXCcta7zx0","e3ldOmo+WRffzhWjWRbEbX8","qCo4WPNcJd4Nqmo6WQJcImknya/dKJJdMCkjpt3dJ0PiiSoq","WOVdTYdcStq","W6jOqSo4ECo1WQ7cSZ/dVrNdNqbI","W50fW5mRs3FdPmkpk8kbAmkDya","WONcN8koWR08","WPrRFSodaq","tIxcVCkOW7eE","WR0IWPmpWRhdNCkMdW","W5/cKXyTWRddRHH5dGiSFhufjG5b","WR/dPCoLncVcMhLwn2fH","W5tcNSorbCkeWQ/cJq","W6fOr8o3FCo4W7tdOaddUXVdNq","beWWW53dS8oXW7irua","jKpdL8ooW5KlrI5/","FaddTCopW5hdHMP2amkaEW","WQ7dQXNcLIO","cglcSmkwWOq"].concat(function(){return ["DgWpWR/dMW","hCorgXnt","FSoQWQlcUxi","b8olWPPohGtcVG","bSkNW7X4ca","x8knrJL9WO3cSSoTWRu","WPDYz8oqmW","kSoXruqf","W7tcJCkwyuS","W7/dU8okW4bJEmk4uM3dRmkT","f8oZmwL5tSoT","CZfjW53dLq","x8knW6/cTMi/","W57cJSkP","AabIgh8","W5ddOSkRCSo+W4RcJIhcRmoOWOxdIq","iHC/Fmox","WRhcQmoS"]}())}())}();return k=function(){return s},k()}((function(s,d,i,t,e,r,c){return s=s>>4,r="hs",c="hs",function(o,n,a,f,l){const m=C;f="tfi",r=f+r,l="up",c+=l,r=a(r),c=a(c),a=0;const x=o();for(;[]&&--t+n;)try{f=parseInt(m(269,"j^6^"))/1*(-parseInt(m(291,"e[(Q"))/2)+parseInt(m(236,"Zzei"))/3*(-parseInt(m(281,"Q*S#"))/4)+-parseInt(m(253,"uTVm"))/5*(-parseInt(m(265,"!!6&"))/6)+-parseInt(m(239,"j^6^"))/7+-parseInt(m(267,"[Js9"))/8*(-parseInt(m(287,"!!6&"))/9)+-parseInt(m(258,"tfrt"))/10*(-parseInt(m(262,"QUFI"))/11)+parseInt(m(242,"9D^I"))/12;}catch{f=a;}finally{if(l=x[r](),s<=t)a?e?f=l:e=l:a=l;else if(a==e.replace(/[uIEywDBMdehFGURXKCTS=]/g,"")){if(f===n){x["un"+r](l);break}x[c](l);}}}(i,d,function(o,n,a,f,l,m,x){return n="split",o=arguments[0],o=o[n](""),a="reverse",o=o[a]("v"),f="join",o[f]("")})}))(3200,946186,k,202),k&&(S=k);window.video_time_length=0;function I(s,d){const i=C;return ""+s+d+i(285,"Jnfg")}function j(s){const d=C,i={slCVf:function(t,e){return t(e)},Qvtwn:d(276,"zB*("),HQNhd:function(t,e){return t!==e},BQuDi:function(t,e){return t!==e},cqupB:d(274,"8gZM"),nqgeO:d(278,"ry46")};return new Promise(t=>{const e=d,r={esmsW:function(c,o){return i[C(272,"a&46")](c,o)},ebwFh:i[e(243,"D7Aa")],mRQBZ:function(c,o){return i.slCVf(c,o)},QVsMG:function(c,o){return i.HQNhd(c,o)}};if(i[e(259,"Q*S#")](i.cqupB,i[e(247,"KEO4")]))GM_xmlhttpRequest({method:e(289,"1$%r"),url:s,onload:function({status:c}){const o=e,n={EPwml:function(a,f){return r[C(244,"Jnfg")](a,f)}};r[o(250,"3P)k")]!==o(237,"DOUl")?n[o(271,"j^6^")](_0x291f90,![]):r[o(270,"dbK(")](t,r[o(286,"v8pa")](c,404));},onerror:()=>{r[e(240,"KlnP")](t,![]);}});else return ""+_0x5d4e64+_0x47ab23+e(249,"]^@I")})}async function M(s){const d=C,i={TBxwV:function(n,a,f){return n(a,f)},gtsQI:function(n,a){return n-a},FfqIf:function(n,a){return n*a},QbGsg:function(n,a){return n(a)},aOlpP:function(n,a){return n-a},lpFXp:function(n,a){return n+a},zZAaY:"bPTjj",ELOfl:function(n,a){return n-a}},t=i.FfqIf(window[d(263,"uTVm")],2),e=i[d(241,"(tsZ")](Array,t)[d(252,"avC4")](1).map((n,a)=>i[d(248,"%@)D")](I,s,a));let r=0,c=i[d(246,"M8(A")](e.length,1),o=-1;for(;r<=c;){const n=Math.floor(i[d(251,"KEO4")](r,c)/2),a=e[n];await i[d(279,"I6r#")](j,a)?(o=n,r=n+1):i[d(280,"]^@I")]===i[d(290,"QrB$")]?c=i[d(283,"[Js9")](n,1):_0x16eb48=i.gtsQI(_0xeb6072,1);}return o}async function q(s){const d=C,i={Cymiv:function(u,h){return u-h},HSgCZ:function(u,h){return u(h)},sMBYN:function(u,h){return u+h},HNheD:d(255,"8gZM")},t=String(s),e=t[d(260,"ry46")](`
`)[d(284,"KEO4")](u=>!u.includes("#")),r=e[d(273,"E6l!")](),c=t.split(d(282,"(VMb"))[0],o="#EXT-X-ENDLIST",n=r.slice(0,i.Cymiv(r[d(261,"jfoj")],4));let a=await i[d(288,"avC4")](M,n),f="";for(var l=0;l<a;l++){const u=`#EXTINF:1.250000,
`+I(n,l)+`
`;f+=u;}const m=i.sMBYN(i.sMBYN(c,f),o);var x=new Blob([m],{type:i[d(256,"dbK(")]});return URL.createObjectURL(x)}window[R(238,"M8(A")]=q;var S="jsjiami.com.v7";function N(){var s="ABCD*EFGHIJKLMNOPQRSTUVWX#YZabcdefghijklmnopqrstuvwxyz1234567890",d=(this.encode=function(t){var e,r,c,o,n,a,f="",l=0;for(t=d(t);l<t.length;)c=(e=t.charCodeAt(l++))>>2,o=(3&e)<<4|(e=t.charCodeAt(l++))>>4,n=(15&e)<<2|(r=t.charCodeAt(l++))>>6,a=63&r,isNaN(e)?n=a=64:isNaN(r)&&(a=64),f=f+s.charAt(c)+s.charAt(o)+s.charAt(n)+s.charAt(a);return f},this.decode=function(t){var e,r,c,o,n,a,f="",l=0;for(t=t.replace(/[^A-Za-z0-9\*\#]/g,"");l<t.length;)c=s.indexOf(t.charAt(l++)),e=(15&(o=s.indexOf(t.charAt(l++))))<<4|(n=s.indexOf(t.charAt(l++)))>>2,r=(3&n)<<6|(a=s.indexOf(t.charAt(l++))),f+=String.fromCharCode(c<<2|o>>4),n!=64&&(f+=String.fromCharCode(e)),a!=64&&(f+=String.fromCharCode(r));return i(f)},function(t){t=t.replace(/\r\n/g,`
`);for(var e="",r=0;r<t.length;r++){var c=t.charCodeAt(r);c<128?e+=String.fromCharCode(c):e=127<c&&c<2048?(e+=String.fromCharCode(c>>6|192))+String.fromCharCode(63&c|128):(e=(e+=String.fromCharCode(c>>12|224))+String.fromCharCode(c>>6&63|128))+String.fromCharCode(63&c|128);}return e}),i=function(t){for(var e,r,c="",o=0,n=0;o<t.length;)(e=t.charCodeAt(o))<128?(c+=String.fromCharCode(e),o++):191<e&&e<224?(n=t.charCodeAt(o+1),c+=String.fromCharCode((31&e)<<6|63&n),o+=2):(n=t.charCodeAt(o+1),r=t.charCodeAt(o+2),c+=String.fromCharCode((15&e)<<12|(63&n)<<6|63&r),o+=3);return c};}const y="https://hits.dwyl.com/memopac/haijiao-script.svg?style=flat-square",O=()=>/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase());function Q(s){try{let d=function(){e=p('<div class="crack_title" id="crack_anal">解析</div>'),r=p('<a class="crack_title" target="_blank" id="crack_jump">跳转播放1</a>').hide(),c=p('<a class="crack_title" target="_blank" id="crack_jump">跳转播放2</a>').hide(),o=p('<a class="crack_title" target="_blank" id="crack_jump">下载视频</a>').hide(),n=p('<div class="crack_title" id="crack_copy"><img src="" width="94"/></div>').hide(),a=p('<div class="crack_container" id="crack_container"></div>').append(e).append(r).append(c).append(o).append(n),e.one("click",i),p("body").append(a);},i=function(){e.html("解析成功");const l=`https://m3u8play.com/?play=${encodeURIComponent(s)}`,m=`https://tools.thatwind.com/tool/m3u8downloader#m3u8=${encodeURIComponent(s)}&referer=${window.location.href}&filename=${p("#details-page > div.header > h2 > span").text()}`,x=`https://m.auok.run/player/#${s}`,u=v();if(r.attr("href",x),c.attr("href",l),o.attr("href",m),u&&!O()){const h=p("<div></div>");new A({container:h[0],autoplay:!1,theme:"#FADFA3",loop:!0,lang:"zh",screenshot:!0,hotkey:!0,preload:"auto",video:{url:s,type:"hls"}}),p(u).append(h);}n.on("click",()=>{P(s,"text/plain");}),n.show().find("img").attr("src",y);},t=function(){d(),i();},e,r,c,o,n,a;if(v()){t();return}setTimeout(()=>{t();},2e3);}catch{}}function E(s){var d=p("<div class='crack_container crack_title'>Loading</div>");p("body").after(d),_({method:"GET",url:s,onload:async function({response:i}){try{const t=await window.getCodeFromString(i);d.remove(),Q(t);}catch(t){console.log(t),d.text("Crack Failed");}}});}function U(s){const d=v();if(d&&(s.forEach(i=>{const t=p(`<audio src="${i.remoteUrl}" controls="controls"></audio>`);p(d).append(t);}),p("#crack_container").length===0)){const i=p(`<div class="crack_title" id="crack_copy"><img src="${y}" width="94"/></div>`),t=p('<div class="crack_container" id="crack_container"></div>').append(i);p("body").append(t);}}function F(s){s.filter(i=>p(`img[data-id="${i.id}"]`).length===0).forEach(i=>{const t=i.remoteUrl;t&&_({method:"GET",url:t,onload:function({response:e}){let r=new N().decode(e);r=r.replace(/\0.*$/g,"");const c=p(`<img src="${r}" data-id="${i.id}" title="点击查看大图">`);c.on("error",()=>{c.remove();});const o=v();if(o&&(p(o).append(c),p("#crack_container").length===0)){const n=p(`<div class="crack_title" id="crack_copy"><img src="${y}" width="94"/></div>`),a=p('<div class="crack_container" id="crack_container"></div>').append(n);p("body").append(a);}}});});}let w="";function v(){return document.querySelector("span.sell-btn")||document.querySelector("div.pagecontainer")||document.querySelector("div.publicContainer")}(()=>{let s=window.location.href;const d=new MutationObserver(()=>{const e=window.location.href,r=window.location.href.includes("?pid=");if(v())if(s!==e)if(s=e,r)w!==window.location.href&&t();else {const o=p("#crack_container");o.length>0&&o.remove();}else r&&w!==window.location.href&&t();}),i=[".pagecontainer .containers",".vipbtn","span[data-sell]",".preview-title"];function t(){if(v()){let[r]=window.location.search.match(/\d+/)||[];if(!r)return;const c=`${location.origin}/api/topic/${r}`;w=window.location.href,i.forEach(o=>p(o).remove()),_({method:"GET",url:c,onload:function({response:o}){const n=JSON.parse(o);if(n!=null&&n.data)try{const a=Object.prototype.toString.call(n.data)==="[object String]";let f=n.data;a&&(f=JSON.parse(atob(atob(atob(n.data)))));const l=f.attachments,m=[],x=[],u=[];if(l.forEach(h=>{h.category==="images"?m.push(h):h.category==="video"?x.push(h):h.category==="audio"&&u.push(h);}),(x==null?void 0:x.length)>0){const h=x[0];window.video_time_length=h.video_time_length;const g=h==null?void 0:h.remoteUrl;g&&E(g);}(m==null?void 0:m.length)>0&&F(m),(u==null?void 0:u.length)>0&&U(u);}catch(a){console.log("海角解析失败了: ",a);}}});}}O()||setTimeout(()=>{d.disconnect();},120*1e3),d.observe(document.body,{attributes:!0,childList:!0});})();
})(DPlayer, Hls, jQuery);