芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/resource.optimyar.com/bbb/optimyar.min.js
function initOptimyar() { console.log("optimyar....."); window.sessionMetadata=null; const meetingId = sessionStorage.getItem("BBB_meetingID"); const userId = sessionStorage.getItem("BBB_externUserID"); const fullName = sessionStorage.getItem("BBB_fullname"); const axiosInstance = axios.create({ baseURL: "https://api.optimyar.com", }); axiosInstance.get(`getMeetingInfoByInteralId/${meetingId}`) .then(response => { const result = response.data; if (!result || result.returncode!=="SUCCESS") { return; } const info= result.attendees.attendee; window.sessionMetadata= {...result.metadata}; let attendees=[]; if (Array.isArray(info)==false){ attendees=[info]; }else{ attendees=info; } const user = attendees.find(x=>x.userID===userId); if (user && user.role==="MODERATOR" && fullName.startsWith("مدرس:")){ console.warn("user is manager"); }else{ if (window.sessionMetadata.disallowrecording){ addRefreshButton(); initForUser(userId,fullName); } removeUserCount(); } }) .catch(error => { console.error("getMeetingInfoByInteralId!!! ", error); }); } function removeUserCount(){ const userColumn = document.querySelector("div[data-test='userList']"); if (userColumn){ const container= userColumn.querySelector("div[class^='sc-']"); if (container){ const h2El= container.querySelector("h2[class^='sc-']"); if (h2El){ h2El.style.display="none"; } } } } function getToken(){ let token = sessionStorage.getItem("optimyarToken"); if (!token) { var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); var userInfoStr = ca.find(c => c.trim().startsWith("OPTIMYAR-USER-INFO")); if (userInfoStr != null) { var str = userInfoStr.replace("OPTIMYAR-USER-INFO=",""); var userInfo = JSON.parse(str); token = userInfo.token; } } return token; } function initForUser(userId,name) { window.allowClose = true; window.isRefreshClick = false; const token = getToken(); if (token) { const axiosInstance = axios.create({ baseURL: "https://api.optimyar.com", headers: { Authorization: `Bearer ${token}` } }); axiosInstance.get("checkSessionLicence") .then(response => { const result = response.data; if (!result) { console.error("user must not be admin"); closeSession(); } window.setWaterMark(null, result); }) .catch(error => { console.error("checkSessionLicence!!! ", error); closeSession(); }); }else{ const phoneNo= userId.split("-").pop(); window.setWaterMark(null, {name,phoneNo}); } } function addRefreshButton(){ const h1El = document.querySelector("h1[data-test='presentationTitle']"); const navBar = h1El.closest("div"); if (navBar){ var button = document.createElement("Button"); button.innerHTML = '
'; button.classList.add('refresh-button'); button.onclick=()=>{ window.isRefreshClick=true; setTimeout(()=>{ window.location.reload(true); //window.isRefreshClick=false; },1000); } navBar.style.position = 'relative'; navBar.appendChild(button); } } function closeSession(){ } function getRandomNumber(from, to) { return Math.floor((Math.random() * to) + from); } function appendHtml(e, t) { var n = document.createElement("div"); for (n.innerHTML = t; n.children.length > 0;) e.appendChild(n.children[0]) } //
function addImageWatermark(){ setInterval(()=>{ videoEl = document.getElementById("screenshareVideo"); if (videoEl){ videoEl= videoEl.closest("div"); videoEl=videoEl.closest("div"); } if (videoEl){ const exist = videoEl.querySelector(".vjs-watermark-content-image"); if (exist){ return; } var img = document.createElement('img'); var div = document.createElement('div'); img.src = "https://resource.optimyar.com/bbb/logo.png"; img.style.width = "100%"; img.style.opacity= 0.3; div.classList.add('vjs-watermark-content-image'); // set text font size div.classList.add("vjs-watermark-center"); div.appendChild(img); setTimeout(function () { videoEl.appendChild(div); }, 1000); } },2*60*1000); } function* shuffle(array) { let i = array.length; while (i--) { yield array.splice(Math.floor(Math.random() * (i+1)), 1)[0]; } } function addWatermark(videoEl, data,position) { let {name, phoneNo} = data; name = name.replace(" null",""); const fontSize=2; //percent; if (videoEl==null){ videoEl = document.getElementById("screenshareVideo"); if (videoEl){ videoEl= videoEl.closest("div"); videoEl=videoEl.closest("div"); }else{ videoEl= document.querySelector("div[data-test='presentationContainer']"); } if (videoEl==null){ console.error("videoEl is null !!! "); return; } } var div = document.createElement('div'); var text = document.createElement('span'); text.innerText = `${name} \n\n ${phoneNo}`; text.style.fontSize = `${fontSize}%`; div.style.zIndex=999999; const updateWatermarkFontSize = function updateWatermarkFontSize() { var height = videoEl.clientWidth; var trueSize = height / 100 * parseFloat(fontSize); text.style.fontSize = trueSize + 'px'; }; window.addEventListener('resize', updateWatermarkFontSize); document.addEventListener('onfullscreenchange',updateWatermarkFontSize); setTimeout(updateWatermarkFontSize, 1000); div.classList.add("vjs-watermark-content"); div.classList.add("vjs-watermark-"+position); div.appendChild(text); setTimeout(function () { videoEl.appendChild(div); div.classList.add("animate__animated"); div.classList.add("animate__lightSpeedInLeft"); }, 1000); setTimeout(()=>{ div.classList.add("animate__lightSpeedOutRight"); setTimeout(()=>{ document.querySelectorAll(`.vjs-watermark-content`).forEach(el => el.remove()); },2000); },22*1000) } window.setWaterMark=(videoEl,userInfo)=>{ let positions= shuffle(['top-left','top-right','bottom-right','bottom-right']); let next = positions.next().value; addWatermark(videoEl,userInfo,next); addImageWatermark(); setInterval(()=>{ next = positions.next().value; if (!next){ positions= shuffle(['top-left','top-right','bottom-right','bottom-right']); next = positions.next().value; } addWatermark(videoEl,userInfo,next); },60*1000*2); } ////
//
document.addEventListener('gesturestart', function (e) { e.preventDefault(); }); // document.addEventListener('readystatechange', event => { // // // When HTML/DOM elements are ready: // if (event.target.readyState === "interactive") { //does same as: ..addEventListener("DOMContentLoaded".. // console.log("interactive"); // setTimeout(()=>{ // initOptimyar(); // },2000); // } // // When window loaded ( external resources are loaded too- `css`,`src`, etc...) // if (event.target.readyState === "complete") { // console.log("load complete"); // } // }); window.onload = function() { setTimeout(()=>{ initOptimyar(); },5*1000); }; // window.addEventListener("beforeunload", function (e) { // if (window.allowClose && !window.isRefreshClick){ // e.preventDefault(); // window.opener=null; // window.close(); // return false; // } // // var confirmationMessage ='آیا برای خروج از جلسه اطمینان دارید؟ '; // // (e || window.event).returnValue = confirmationMessage; //Gecko + IE // return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc. // }); // // window.addEventListener('popstate', function (){ // var confirmationMessage ='آیا برای خروج از جلسه اطمینان دارید؟ '; // // (e || window.event).returnValue = confirmationMessage; //Gecko + IE // return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc. // }); //