// ==UserScript==
// @name KI-Hécate-MinichatPlus
// @description Améliore le minichat de Kraland
// @match http://www.kraland.org/*
// @version 3.0.0
// @author Gyeongeun
// @license CC BY-SA
// @namespace Gyeongeun_31399
// @grant none
// @exclude http://www.kraland.org/map.php*
// @exclude http://www.kraland.org/help.php*
// @exclude http://www.kraland.org/report.php*
// @exclude http://www.kraland.org/order.php*
// @noframes
// ==/UserScript==
//+------------ Options par défaut --------------+
const Blacklist = {};
// Rajoutez les id entre les crochets ci-dessus au format id:"nom",
// exemple : {1:"redstar", 644:"krabot", 31399:"gyeongri"}
// Vous pouvez mettre le nom entre guillemet comme bon vous semble, seule l'id est prise en compte.
const Anonymes = false;
// false pour supprimer les messages d'anonymes.
const SmileysNormaux = false;
// true pour taille normale, false petite taille,
const EpinglerLesMenus = false;
// true pour épingler les menus de Kraland
var tailleMinichat = "380";
// longueur du minichat en pixels (par défaut : 420)
const HecatePlus = "";
// Entête du minichat : "kpop", "PandiPanda", "RyckoHub"
var HecateTV = "";
// "kpopTV", "PandiPandaTV", "RyckoHubTV" ou "MaPlaylist" pour afficher une miniTV !
var HecateMyTV = "";
// Entrez l'url de votre propre playlist par défaut
//+------------ Paramétrages du Script --------------+
//--- Variables Globales
var kdocument=document;
var idTimeout,csstyle;
var param = {
nameList: Object.assign({}, Blacklist),
anonymes: Anonymes,
minichatSize : tailleMinichat,
smSize: SmileysNormaux,
hecatePlus: HecatePlus,
hecateTV: HecateTV,
hecateMyTV: HecateMyTV,
pinup: EpinglerLesMenus,
//rfilter: filtre
};
//--- Initialisation
Melinoe();
function Melinoe(){
if(window.location.href=="http://www.kraland.org/"){
location.replace("http://www.kraland.org/main.php");
}
sessionStorage.kstyle=parseInt(kdocument.head.querySelector('link').href.split('/')[4]);
sessionStorage.lastd=kdocument.querySelector('#minichat .right-box-title').innerHTML;
//--- accès aux paramètres sauvegardés
if(localStorage.hecateparam){
param=JSON.parse(localStorage.hecateparam);
}else{
opReset();
}
csstyle=Number(sessionStorage.kstyle);
}
//+------------ Exécution de Hécate --------------+
HecateOurania()
if(param.pinup){Trioditis();}
Soteira();
PhosphorosLite();
//+------------ Hécate Plus Plus --------------+
function HecateOurania(){
switch(param.hecateTV){
case "kpopTV" : HecateMedia("PLtp7_6Uhd19fn0_Xvi6uzGIzaa253hrBf");
break;
case "RyckoHubTV" : HecateMedia("PLtp7_6Uhd19eeGfewW-Mk7xnqGwlJxRyc");
break;
case "PandiPandaTV" : HecateMedia("PLtp7_6Uhd19fQpoVHoc8StL4u9rjbwYqy");
break;
case "myTV" : HecateMedia(param.hecateMyTV);
break;
default: EnoDisplay();
}}
function EnoDisplay(){
switch(param.hecatePlus){
case "kpop" : Enodia("https://www.youtube-nocookie.com/embed/videoseries?list=PLtp7_6Uhd19fn0_Xvi6uzGIzaa253hrBf", "♬ ♫ ♪ ♩ Kpop ♩ ♪ ♫ ♬");
break;
case "RyckoHub" : Enodia("https://www.youtube-nocookie.com/embed/videoseries?list=PLtp7_6Uhd19eeGfewW-Mk7xnqGwlJxRyc", "🍑🍆RyckoHub🍆🍑");
break;
case "PandiPanda" : Enodia("https://www.youtube-nocookie.com/embed/videoseries?list=PLtp7_6Uhd19fQpoVHoc8StL4u9rjbwYqy", "♫ ♪ Pandi Panda ♪ ♫<br>♩ Techno🐼Remix ♩");
break;
default: var miniH=kdocument.getElementById('miniHeader');
if(miniH){miniH.parentNode.removeChild(miniH);}
}}
function Enodia(aLink, aText){
var aUL = kdocument.createElement('UL');
var aLI = kdocument.createElement('LI');
var kpop = kdocument.createElement('A');
aUL.appendChild(aLI);
aLI.appendChild(kpop);
aUL.className = 'right-boxminichat-list';
aUL.id = 'miniHeader';
kpop.href = aLink;
kpop.target ='_blank';
kpop.style.textAlign = "center";
kpop.innerHTML = aText;
var lilist = kdocument.querySelector('#minichat').parentNode;
lilist.insertBefore(aUL, lilist.firstElementChild);
}
function Triformis(aTitle){
var mTitle=kdocument.querySelector('#right .right-box-header');
mTitle.id="mTitle";
var nTitle;
switch(aTitle){
case 0 : nTitle="MINI-CHAT";
mTitle.innerHTML=nTitle;
break;
case 1 :
nTitle="Rapport Privé";
if(csstyle==3){nTitle="RAPPORT";}
mTitle.innerHTML=nTitle;
break;
case 2 :
mTitle.innerHTML="";
EnodiaCtrl(mTitle);
break;
default: return;
}
}
//+------------Hécate Maxichat--------------+
function Soteira(){
//---variables générales
var mc=kdocument.getElementById('minichat');
var mcp=kdocument.getElementById('minichat').parentNode;
var mcpp=kdocument.getElementById('minichat').parentNode.parentNode;
var minichatSize = param.minichatSize;
if(param.hecateTV!=""){minichatSize-=70;}
// hauteur du minichat en pixels.
kdocument.getElementById('right-img').style.zIndex=-1;
//---suppression de la barre de défilement
if(navigator.userAgent.includes('Firefox')){
mcp.style.scrollbarWidth = 'none';
mcpp.querySelector('.right-box-message').style.scrollbarWidth = 'none';
}else{
var wbk=kdocument.createElement('STYLE');
wbk.innerHTML=('.mcbox::-webkit-scrollbar{width:0px;} .right-box-message::-webkit-scrollbar{width:0px;}')
mcpp.appendChild(wbk);
}
//---Retrait du nom grisé
var greyInput=kdocument.querySelector('.fl');
greyInput.parentNode.removeChild(greyInput);
//---taille du minichat
var theMaxHeight = minichatSize+"px";
mcpp.style.maxHeight = theMaxHeight;
mcp.style.maxHeight = theMaxHeight;
mc.style.maxHeight = theMaxHeight;
var theHeight = minichatSize+"px";
mcpp.style.height = theHeight;
mcp.style.height = theHeight;
mc.style.height = theHeight;
//---sélection Header
var topHead=kdocument.getElementById('header');
//---couleur de fond du minichat selon l'interface
switch(csstyle){
//- thème kraland
case 0: setBgColor(mcp,'#F5F2F8');
setButton('#F5F2F8','solid','123px','16px', '14px');
kdocument.querySelector('#right textarea').style.width='125px';
//- bordure
mcp.style.borderRight='2px solid #581315';
mcp.style.borderBottom='2px solid #581315';
//- header
headerBgImg(document.body);
//-mTitle
kdocument.querySelector('#right .right-box-header').style.padding='15px 0px 7px 7px';
//kdocument.querySelectorAll('.new-box-button').forEach();
Kleidukos("20px","#595959");
break;
//- thème médiéval
case 1: setBgImg(mcpp);
setBox('2px groove #000000','130px','16px');
setButton('','none','118px','12px');
kdocument.querySelector('#right textarea').style.width='120px';
Kleidukos("20px","#333333");
break;
//- thème gris
case 2: setBgImg(mcp);
setBgColor(mcp,'#F9F9F9');
setBgColor(mcpp,'#FFFFFF');
kdocument.querySelector('#right textarea').style.width='125px';
//- bordure
setBox('2px solid #DEDEDE', '131px');
mcpp.style.borderTop='none';
mcp.style.borderLeft='2px double #F9F9F9';
mcp.style.borderRight='4px double #F9F9F9';
//- header
setBgColor(topHead,'#FFFFFF');
Kleidukos("24px","#595959");
break;
//- thème standard
case 3: setBgImg(mcp);
setBox('none','130px');
kdocument.querySelector('#right textarea').style.width='130px';
//- bordure
mcp.style.borderRight='5px solid #F0F1EB';
mcp.style.borderLeft='5px solid #F0F1EB';
mcp.style.borderBottom='2px solid #DEDED2';
Kleidukos("24px","#595959");
break;
//- thème Moderne
case 4: {setBgColor(mcp,'#F5F2F8');
mcp.style.borderRight='1px double #C8C8C7';
mcp.style.borderBottom='1px double #C8C8C7';
kdocument.querySelector('#right textarea').style.width='125px';
Kleidukos("24px","#595959");
//- <li>title
lititle();
//-mini-header
kdocument.querySelector('#right .right-box-header').style.height='20px';
kdocument.querySelector('#right .right-box-header').style.lineHeight='26px';
//- header
topHead.style.padding='0px';
kdocument.getElementById('framemenu').style.top='65px';
kdocument.getElementById('header-left').style.margin='12px';
kdocument.querySelectorAll('#divmenu .menu').forEach(upperm);
function upperm(subm){subm.style.marginTop='-22px';}
//-- main
kdocument.getElementById('central-content').style.marginTop='0px';
kdocument.getElementById('left').style.paddingTop='0px';
kdocument.getElementById('right').style.paddingTop='0px';
break;}
default: setBgColor(mcp,'#F5F2F8');
}
//---image de fond minichat
function setBgImg(aNode){
var bgleft = kdocument.getElementById('left');
var bgimg = window.getComputedStyle(bgleft).backgroundImage;
aNode.style.backgroundImage=bgimg;
aNode.style.backgroundRepeat='repeat-y';
}
//---image de fond header
function headerBgImg(aNode){
let topHead=kdocument.getElementById('header');
var bgimg = window.getComputedStyle(aNode).backgroundImage;
topHead.style.backgroundImage=bgimg;
topHead.style.backgroundRepeat='repeat-x';
}
//---ajustement des boutons
function setButton(aColor, aBorder, w, h, s){
var rfb=kdocument.querySelectorAll('#right .right-box-button img');
rfb.forEach(imgBorder);
function imgBorder(bimg){
bimg.style.height=s;
bimg.style.width=s;
}
var rfp=kdocument.querySelector('#right .right-box-button').parentNode;
rfp.style.width=w;
rfp.style.height=h;
rfp.style.backgroundColor=aColor;
rfp.style.border='2px '+aBorder+' '+aColor;
rfp.style.borderRadius='2px';
}
//---mise en forme du cadre
function setBox(bparam, rbSize){
var dasize = parseInt(minichatSize)+67;
mcpp.style.maxHeight=dasize+'px';
mcpp.style.height=dasize+'px';
mcpp.style.paddingLeft = '5px';
mcpp.style.marginLeft = '5px';
mcpp.style.width = rbSize;
mcpp.style.border = bparam;
}}
//--- <li><a>color Kraland
function aColor(oneColor){
kdocument.getElementById('minichat').querySelectorAll('A').forEach(lColor);
function lColor(alink){alink.style.color=oneColor;}
}
//---couleur de fond
function setBgColor(aNode,aColor){
aNode.style.backgroundColor=aColor;
}
//---<li>title Moderne
function lititle(){
kdocument.querySelectorAll('#right .right-box-title').forEach(dateli);
function dateli(ali){ali.style.height='5px'; ali.style.lineHeight='5px';}
}
//+------------ Epingler les menus ---------------+
function Trioditis(){
if(param.pinup){
//---Epingler des menus
kdocument.getElementById('header').style.position='fixed';
kdocument.getElementById('framemenu').style.position='fixed';
kdocument.getElementById('divmenu').style.position='fixed';
var framemenu = kdocument.getElementById('framemenu');
var aMargin=parseInt(window.getComputedStyle(framemenu).top);
aMargin=aMargin+parseInt(window.getComputedStyle(framemenu).height);
kdocument.getElementById('right').style.position='fixed';
kdocument.getElementById('left').style.position='fixed';
kdocument.getElementById('right').style.top=aMargin+'px';
kdocument.getElementById('left').style.top=aMargin+'px';
kdocument.getElementById('header').style.zIndex='4';
kdocument.getElementById('framemenu').style.zIndex='4';
}else{
kdocument.getElementById('header').style.position='absolute';
kdocument.getElementById('framemenu').style.position='absolute';
kdocument.getElementById('divmenu').style.position='absolute';
kdocument.getElementById('right').removeAttribute('style');
kdocument.getElementById('left').removeAttribute('style');
}}
//+------------ New Buttons ---------------+
function Kleidukos(fSize,color){
var mchatform = kdocument.getElementsByName('minichatform')[0];
mchatform.setAttribute('id','mchatf');
mchatform.querySelector('.right-box-button').setAttribute('id','mrefresh');
mchatform.getElementsByClassName('right-box-button')[1].setAttribute('id','msend');
mchatform.querySelectorAll('.right-box-button').forEach(removeOnc);
function removeOnc(item){
item.removeAttribute("onclick");
}
var lbutton = kdocument.createElement("BUTTON");
lbutton.setAttribute('id','loadc');
lbutton.setAttribute('class','new-box-button');
lbutton.setAttribute('type','button');
lbutton.innerHTML="↶";
lbutton.style.lineHeight="7px";
var smenu = kdocument.createElement("BUTTON");
smenu.setAttribute('id','bmenu');
smenu.setAttribute('class','new-box-button');
smenu.setAttribute('type','button');
smenu.innerHTML="≡";
smenu.style.lineHeight="12px";
smenu.addEventListener('click',Enitharmon,false);
var sbutton = kdocument.createElement("BUTTON");
sbutton.setAttribute('id','sbutton');
sbutton.setAttribute('class','new-box-button');
sbutton.setAttribute('type','button');
sbutton.innerHTML="🗗";
sbutton.style.lineHeight="12px";
sbutton.addEventListener('click',Phosphoros,false);
mchatform.querySelectorAll('p')[1].style.textAlign='right';
mchatform.querySelectorAll('p')[1].appendChild(lbutton);
mchatform.querySelectorAll('p')[1].appendChild(sbutton);
mchatform.querySelectorAll('p')[1].appendChild(smenu);
mchatform.querySelectorAll('.new-box-button').forEach(cssb);
function cssb(item){
item.style.display='table-cell';
item.style.padding='0px';
item.style.fontSize=fSize;
item.style.verticalAlign="top";
item.style.color=color;
item.style.marginLeft='2px';
item.style.marginRight='2px';
}
}
function sendMsgChat(){
var msgArea = kdocument.querySelector('#right .right-box-message');
if(msgArea.value!=""){
var requested;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
requested = this.responseText;
}};
var msgUrl = "minichat.php?p1=" + encodeURIComponent(msgArea.name) + "&message=" + encodeURIComponent(msgArea.value);
xhttp.open("GET", msgUrl, true);
xhttp.overrideMimeType('text/html');
xhttp.send(null);
}
msgArea.value = "";
sessionStorage.lastd="aujourd'\hui";
HecateOnclick();
}
//+------------ Hécate Blacklist --------------+
function Atropaia(){
//---filtre basique mini-chat
let i;
for(i=0;i<param.blacklist.length;i++){
var dalist = kdocument.getElementById('minichat').getElementsByTagName('A');
let j = dalist.length;
while(j--){
var orilink = dalist[j].getAttribute('href');
if((orilink==param.blacklist[i] && orilink!=null) || (orilink==null && !param.anonymes && dalist[j].id!="return")){
var first=dalist[j].parentNode.nextSibling;
var second=dalist[j].parentNode;
first.parentNode.removeChild(first);
second.parentNode.removeChild(second);
}
}
}
//---filtre archives mini-chat
var anelement=kdocument.getElementById('central-text').firstElementChild.nextSibling;
if(anelement.innerHTML=="Archives du Mini-Chat"){
let dalogs= kdocument.getElementById('central-text').getElementsByTagName('TR');
let k = dalogs.length;
while(k--){
if(dalogs[k].firstElementChild.tagName!="TH"){
var urLink=dalogs[k].children[1].getElementsByTagName('A')[0];
if((typeof urLink !== 'undefined' && param.blacklist.includes(urLink.getAttribute('href'))) || (typeof urLink == 'undefined' && !param.anonymes)){
dalogs[k].parentNode.removeChild(dalogs[k]);
}
}}
}}
//+------------ Hécate Reloaded ---------------+
function Hecate(){
sessionStorage.removeItem('mcount');
var nbMsg=20;
if(typeof(sessionStorage.lilogs)=='undefined'){
loadChat(nbMsg);
Chthonia(nbMsg);
}else{
Chthonia(nbMsg);
idTimeout=setTimeout(function(){loadChat(nbMsg);Chthonia(nbMsg);}, 5000);
}
}
function HecateOnclick(){
sessionStorage.removeItem('mcount');
var nbMsg=20;
loadChat(nbMsg);
Chthonia(nbMsg);
}
function Propolos(){
var nbMsg;
if(sessionStorage.mcount){
nbMsg=Number(sessionStorage.mcount)+20;
}else{
nbMsg=40;
}
sessionStorage.mcount=nbMsg;
var lilines=JSON.parse(sessionStorage.lilogs);
if(lilines.length<nbMsg){
loadChat(nbMsg);
}
Chthonia(nbMsg);
}
//--- Assemble et injecte les logs
function Chthonia(nbMsg){
var lilines=JSON.parse(sessionStorage.lilogs);
var dachat=[];
for(let i=0;i<nbMsg;i++){
dachat[i]=lilines[i];
}
dachat.unshift('<li class="right-box-title" id="mtop">'+sessionStorage.lastd+'</li>');
dachat.push('<li class="note" id="mbottom"><a id="return">⇞ revenir au début</a></li><li class="note">Hécate Minichat Plus v3.0</li>');
var ULchat=kdocument.querySelector('#minichat UL');
ULchat.innerHTML=dachat.join('');
//---<li>title moderne
if(csstyle==4){lititle();}
if(csstyle==0){aColor('#FFFFFF');}
//---
Ariane();
}
//--- Remplace le lien Archives
function Ariane(){
var anA=kdocument.querySelector('#mbottom');
anA.addEventListener('click',arTop,false);
anA.style.cursor='pointer';
function arTop(){
var lilist = kdocument.querySelector('#minichat').parentNode;
lilist.scrollTop=0;
}
}
//+------------Récup des archives---------------+
function loadChat(nb){
sessionStorage.removeItem('lilogs');
var mArchives=loadPage('http://www.kraland.org/main.php?p=6_6');
var aLast=parseInt(mArchives.querySelector('#central-text P A.forum-selpage').innerHTML);
//---charge la première page
var mLogs=mArchives.querySelectorAll('#central-text TR');
var FDatas=mFilter(mLogs);
mLogs=FDatas[0];
var t=FDatas[1];
//---charge de nouvelles pages
if(t<nb){
var n=1;
while(t<nb){
let p=aLast-n;
if(p<1){break;}
let address=mURL(p);
mArchives=loadPage(address);
var newLogs=mArchives.querySelectorAll('#central-text TR');
FDatas=mFilter(newLogs);
newLogs=FDatas[0];
t=t+FDatas[1];
mLogs=mLogs.concat(newLogs);
n++;
}}
//---conversion des lignes en <li> et css
var nDate= new Date();
if(sessionStorage.lastd!="aujourd'hui"){
let lDate=sessionStorage.lastd.split('-');
let sDate=lDate[2]+'-'+lDate[1]+'-'+lDate[0];
nDate= new Date(sDate);
}
mLogs.forEach(parseToLi);
function parseToLi(item,index,arr){
if(!param.smSize){item.querySelectorAll('img').forEach(cssimg);
function cssimg(animg){
animg.width=12;
animg.height=12;
animg.border=0;
animg.align='middle';
}}
if(item.firstElementChild.tagName!='TH'){
var dualTD=item.querySelectorAll('TD');
var lheure='<span class="hour"> '+dualTD[1].innerHTML.match(/\([0-2][0-9]\:[0-5][0-9]\)/i)+'</span> ';
dualTD[1].innerHTML=dualTD[1].innerHTML.replace(/\([0-2][0-9]\:[0-5][0-9]\)/i,"");
var fprofil=lheure+dualTD[1].querySelector('A').innerHTML;
dualTD[1].querySelector('A').innerHTML=fprofil;
arr[index]='<li>'+dualTD[1].innerHTML+'</li><li>'+dualTD[2].innerHTML+'</li>';
}else{
nDate.setDate(nDate.getDate()-1);
let nDay=("0" + nDate.getDate()).slice(-2);
let nMonth=("0" + (nDate.getMonth() + 1)).slice(-2);
arr[index]='<li class="right-box-title">'+nDay+'-'+nMonth+'-'+nDate.getFullYear()+'</li>';
}
}
sessionStorage.setItem("lilogs", JSON.stringify(mLogs));
return mLogs;
}
//---Filtre
function mFilter(TrNodes){
//var TrList=Array.prototype.slice.call(TrNodes);
var TrList=Array.from(TrNodes);
TrList.shift();
var k = TrList.length;
var countTh=0;
while(k--){
if(TrList[k].firstElementChild.tagName!="TH"){
var urLink=TrList[k].children[1].getElementsByTagName('A')[0];
if((typeof urLink !== 'undefined' && param.blacklist.includes(urLink.getAttribute('href'))) || (typeof urLink == 'undefined' && !param.anonymes)){
TrList.splice(k,1);
}else if(typeof urLink == 'undefined' && param.anonymes){
TrList[k].children[1].innerHTML="<a>"+TrList[k].children[1].innerHTML+"</a>";
}
}else{
countTh++;
}}
k=TrList.length;
var t=k-countTh;
TrList.reverse();
var TrDatas=[TrList,t];
return TrDatas;
}
//---GET request
function loadPage(theURL){
var requested;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
requested = this.responseText;
}
};
xhttp.open("GET", theURL, false);
xhttp.overrideMimeType('text/html; charset=iso-8859-1');
xhttp.withCredentials;
xhttp.send(null);
var parser = new DOMParser();
var htmlDoc = parser.parseFromString(requested, "text/html");
return htmlDoc;
}
//---Convertis en url des archives
function mURL(n){
let aLink='http://www.kraland.org/main.php?p=6_6_0_'+n;
return aLink;
}
//+------------ Switch to Report ---------------+
function Phosphoros(){
var mp=kdocument.getElementById('minichat');
//var rStatus=kdocument.querySelector('#report');
if(param.isreport){
kdocument.getElementById('msend').removeEventListener('click',Omilia,false);
kdocument.getElementById('loadc').removeEventListener('click',Skotia,false);
kdocument.getElementById('loadc').removeEventListener("dblclick", function(){location.href="http://www.kraland.org/report.php?p2=2";},false);
Triformis(0);
sessionStorage.removeItem("liDatas");
param.isreport=false;
localStorage.hecateparam=JSON.stringify(param);
mp.innerHTML='<div word-wrap: break-word;><ul class="right-boxminichat-list"></ul></div>';
kdocument.getElementById('loadc').addEventListener('click',Propolos,false);
kdocument.getElementById('loadc').addEventListener("dblclick", function(){location.href="http://www.kraland.org/main.php?p=6_6";},false);
HecateOnclick();
kdocument.getElementById('msend').addEventListener('click',sendMsgChat,false);
}else{
clearTimeout(idTimeout);
kdocument.getElementById('msend').removeEventListener('click',sendMsgChat,false);
kdocument.getElementById('loadc').removeEventListener('click',Propolos,false);
kdocument.getElementById('loadc').removeEventListener("dblclick", function(){location.href="http://www.kraland.org/main.php?p=6_6";},false);
Triformis(1);
param.isreport=true;
localStorage.hecateparam=JSON.stringify(param);
kdocument.getElementById('loadc').addEventListener('click',Skotia,false);
kdocument.getElementById('loadc').addEventListener("dblclick", function(){location.href="http://www.kraland.org/report.php?p2=2";},false);
Perseis(0);
kdocument.getElementById('msend').addEventListener('click',Omilia,false);
}
if(param.hecateTV!=""){setTimeout(function(){Triformis(2);}, 1000);}
}
function PhosphorosLite(){
Atropaia();
//var rStatus=kdocument.querySelector('#report');
if(param.isreport){
Triformis(1);
kdocument.getElementById('loadc').addEventListener('click',Skotia,false);
kdocument.getElementById('loadc').addEventListener("dblclick", function(){location.href="http://www.kraland.org/report.php?p2=2";},false);
Circe();
kdocument.getElementById('msend').addEventListener('click',Omilia,false);
kdocument.getElementById('mrefresh').addEventListener('click',PerseisLite,false);
}else{
Triformis(0);
kdocument.getElementById('loadc').addEventListener('click',Propolos,false);
kdocument.getElementById('loadc').addEventListener("dblclick", function(){location.href="http://www.kraland.org/main.php?p=6_6";},false);
Hecate();
kdocument.getElementById('msend').addEventListener('click',sendMsgChat,false);
kdocument.getElementById('mrefresh').addEventListener('click',HecateOnclick,false);
}
}
//+------------ Injection du rapport privé ---------------+
function Perseis(n){
var rArchive=loadPage('http://www.kraland.org/report.php?p2='+n);
let oneURL=rArchive.querySelectorAll(".on")[0].firstChild.getAttribute("href");
param.playerId=oneURL.replace("report.php?p=0&p1=","");
//--- traitement image
var allImg=rArchive.getElementsByTagName('IMG');
for(let i=0;i<allImg.length;i++){
allImg[i].style.maxWidth='130px';
}
//--- filtre et préparation à la mise en forme
var actionList=rArchive.querySelectorAll('#report .forum')[0].getElementsByTagName('TR');
for(var j=0;j<actionList.length;j++){
var action=actionList[j].getElementsByTagName('TD')[1].innerHTML;
//--- filtres
/* rfilters */
//--- traitement texte
var theAction=" "+action;
var remain=null;
if(action.indexOf(" : ")>0){
action=action.split(" : ");
theAction=" "+action.shift()+" : ";
remain=action.join(" : ");
}
actionList[j].getElementsByTagName('TD')[0].innerHTML+=theAction;
actionList[j].getElementsByTagName('TD')[1].innerHTML=remain;
}
var aLogs=Array.from(actionList);
aLogs.forEach(parseToLi);
function parseToLi(item,index,arr){
var descrp=item.getElementsByTagName('TD')[0];
var acting=item.getElementsByTagName('TD')[1];
arr[index]='<li><a>'+descrp.innerHTML+'</a></li><li>'+acting.innerHTML+'</li>';
}
//--- formatage
aLogs.push('<li class="note" id="mbottom"><a id="return">⇞ revenir au début</a></li><li class="note">Hécate Minichat Plus v3.0</li>');
var ULchat=kdocument.querySelector('#minichat UL');
ULchat.innerHTML=aLogs.join('');
sessionStorage.setItem("rlilogs", JSON.stringify(aLogs));
//---
Ariane();
}
//--- Récupération du rapport étendu
function Skotia(){
Perseis(1);
kdocument.getElementById('loadc').addEventListener('click',SkotiaPlus,false);
}
function SkotiaPlus(){
Perseis(2);
}
function PerseisLite(){
Perseis(0);
}
//--- Rapport en cache
function Circe(){
if(typeof(sessionStorage.rlilogs)=='undefined'){
Perseis(0);
}else{
var aLogs=JSON.parse(sessionStorage.getItem("rlilogs"));
var ULchat=kdocument.querySelector('#minichat UL');
ULchat.innerHTML=aLogs.join('');
Ariane();
idTimeout=setTimeout(function(){Perseis(0);}, 2000);
}
}
//+------------ S'adresser à tous ---------------+
//--- Envoie du message
function Omilia(){
var msgArea = kdocument.querySelector('#right .right-box-message');
var oParam=tha();
var t=oParam[0];
var n=oParam[1];
var p=encodeURIComponent('2_2');
var msg=msgArea.value;
var ok=encodeURIComponent('Ok!');
fetch('http://www.kraland.org/main.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
'p': p,
'a': 1,
't': t,
'n': n,
'p1': 300204,
'p2': param.playerId,
'p3': 2,
'message': msg,
'p12':1,
'submit':ok
})
})
// .then(res => { // Do stuff with the result});
msgArea.value = "";
Perseis(0);
}
//--- Récupération des données
function tha(){
var urlOrder="http://www.kraland.org/order.php?p1=3002&p2="+param.playerId;
var PageOrders=loadPage(urlOrder);
var oParam=[];
oParam[0]=PageOrders.getElementById("order300204").querySelector("input[name='t']").value;
oParam[1]=PageOrders.getElementById("order300204").querySelector("input[name='n']").value;
return oParam;
}
//+------------ Options Minichat ---------------+
function opReset(){
param = {
nameList: Object.assign({}, Blacklist),
anonymes: Anonymes,
minichatSize : tailleMinichat,
smSize: SmileysNormaux,
hecatePlus: HecatePlus,
hecateTV: HecateTV,
hecateMyTV: HecateMyTV,
pinup: EpinglerLesMenus,
isreport: param.isreport,
//rfilter: param.filter
};
//--- mise en forme des IDs
var provList=[];
for(var anid in param.nameList){
if(!provList.includes("main.php?p=6_1&p1="+anid)){
provList.push("main.php?p=6_1&p1="+anid);
}}
param.blacklist=provList;
//--- sauvegarder
localStorage.hecateparam=JSON.stringify(param);
}
function Enitharmon(){
var mp=kdocument.getElementById('minichat');
var EniStatus=kdocument.querySelector('#opBoard');
if(EniStatus){
sessionStorage.removeItem("liDatas");
mp.innerHTML='<div word-wrap: break-word;><ul class="right-boxminichat-list"></ul></div>';
if(param.isreport){Perseis(0);}else{HecateOnclick();}
}else{
var lilines=mp.innerHTML;
mp.innerHTML=opBoard();
kdocument.getElementById('urlTV').value=param.hecateMyTV;
var opm=kdocument.getElementById('opBoard');
opm.style.textAlign='left';
opm.style.fontSize='9px';
opm.style.height='274px';
opm.style.paddingLeft='5px';
opm.style.paddingTop='10px';
opm.style.paddingBottom='10px';
opm.scrollTo(0,opm.scrollHeight);
opm.querySelector('#vbutton').addEventListener('click',opValidate,false);
opm.querySelector('#rbutton').addEventListener('click',opResetM,false);
//--- fréquentations du minichat
var parser = new DOMParser();
lilines = parser.parseFromString(lilines, "text/html");
var pLink = lilines.querySelectorAll('a[href*="main.php?p=6_1&p1="]');
var pList={};
for(var i=0; i<pLink.length; i++){
pLink[i].removeChild(pLink[i].firstChild);
var oneID=pLink[i].href.replace('http://www.kraland.org/main.php?p=6_1&p1=','');
if(!(oneID in pList)){pList[oneID]=pLink[i].innerHTML;}
}
var pSelect='<option value="" selected></option>';
for(var Id in pList){
pSelect+='<option value="'+Id+'">'+pList[Id]+'</option>';
}
kdocument.getElementById('ablist').innerHTML=pSelect;
opSetValue();
}
function opBoard(){
var Bform=`<form id="opBoard">HécateTV :<br>
<select id="opHTV">
<option value="">Aucune</option>
<option value="kpopTV">kpop</option>
<option value="RyckoHubTV">RyckoHub</option>
<option value="PandiPandaTV">Pandi Panda</option>
<option value="myTV">MyTV</option>
</select><br><input type="text" id="urlTV" placeholder="ID de la playlist">
<br><br>Entête :<br>
<select id="opHPlus">
<option value="">Aucun</option>
<option value="kpop">kpop</option>
<option value="RyckoHub">RyckoHub</option>
<option value="PandiPanda">Pandi Panda</option>
</select><br><br>Taille Minichat :<br>
<input type="number" id="mSz" title="Taille du minichat en px" placeholder=""><br>
<input type="checkbox" id="smileySz"><label for="smileySz">Smileys normaux</label><br>
<input type="checkbox" id="bPinup"><label for="bPinup">Epingler les menus</label><br>
<input type="checkbox" id="bNymes"><label for="bNymes">Anonymes</label><br>
<br>
Retirer de la blacklist :
<select id="rblist">
</select><br>
Ajouter à la blacklist :
<select id="ablist">
</select><br><br>
<input type="button" value="Valider" id="vbutton"> <input type="button" value="Reset" id="rbutton">
</form>
<style>#opBoard input{height:auto; Max-Width:114px;}
#opBoard select{width:120px;}
</style>`;
return Bform;
}
}
function opResetM(){
var exHTV=param.hecateTV;
var miniH=kdocument.getElementById('miniHeader');
if(miniH){miniH.parentNode.removeChild(miniH);}
opReset();
opSetValue();
HecateOurania();
if(param.hecateTV!=exHTV){
window.location.reload();
}
}
function opValidate(){
var exHTV=param.hecateTV;
param.hecateTV = kdocument.getElementById('opHTV').value;
param.hecatePlus = kdocument.getElementById('opHPlus').value;
param.smSize = kdocument.getElementById('smileySz').checked;
param.pinup = kdocument.getElementById('bPinup').checked;
param.anonymes = kdocument.getElementById('bNymes').checked;
param.hecateMyTV = kdocument.getElementById('urlTV').value;
var mSzV=kdocument.getElementById('mSz').value;
if(mSzV==""){mSzV=tailleMinichat}
if(mSzV<150){mSzV=150}
param.minichatSize = mSzV;
var removeB=kdocument.getElementById('rblist');
if(removeB.value!=""){
delete param.nameList[removeB.value];
var index = param.blacklist.indexOf("main.php?p=6_1&p1="+removeB.value);
if(index > -1) {param.blacklist.splice(index, 1);}
removeB.remove(removeB.selectedIndex);
}
var addN=kdocument.getElementById('ablist');
if(addN.value!=""){
param.blacklist.push('main.php?p=6_1&p1='+addN.value);
if(!(addN.value in param.nameList)){param.nameList[addN.value]=readText('ablist');}
addN.remove(addN.selectedIndex);
}
opSetValue();
//--- sauvegarder
localStorage.hecateparam=JSON.stringify(param);
Trioditis();
var miniH=kdocument.getElementById('miniHeader');
if(miniH){miniH.parentNode.removeChild(miniH);}
HecateOurania();
if(kdocument.getElementById('opHTV').value!=exHTV){
param.hecatePlus=kdocument.getElementById('opHTV').value.replace('TV','');
localStorage.hecateparam=JSON.stringify(param);
window.location.reload();
}
}
function readText(anID){
var o=kdocument.getElementById(anID);
var txt= o.options[o.selectedIndex].text;
return txt;
}
function opSetValue(){
kdocument.getElementById('opHTV').value = param.hecateTV;
kdocument.getElementById('opHPlus').value = param.hecatePlus;
kdocument.getElementById('smileySz').checked = param.smSize;
kdocument.getElementById('bPinup').checked = param.pinup;
kdocument.getElementById('bNymes').checked = param.anonymes;
kdocument.getElementById('mSz').placeholder=tailleMinichat;
if(param.minichatSize!=tailleMinichat){
kdocument.getElementById('mSz').value=param.minichatSize;
}
//--- blacklist
var dropNames='<option value="" selected></option>';
for(var idName in param.nameList){
dropNames+='<option value="'+idName+'">'+param.nameList[idName]+'</option>';
}
kdocument.getElementById('rblist').innerHTML=dropNames;
}
//+------------ Hecate Media Player --------------+
function HecateMedia(playlistId){
if(document.getElementById('krabox')==null){
//--- gestion des styles
switch(csstyle){
//- thème kraland
case 0: sessionStorage.topp=JSON.stringify([250,60,0.4,1.1]);
break;
//- thème médiéval
case 1: sessionStorage.topp=JSON.stringify([262,70,0.4,1.1]);
break;
//- thème gris
case 2: sessionStorage.topp=JSON.stringify([261,72,0.4,1.1]);
break;
//- thème standard
case 3: sessionStorage.topp=JSON.stringify([261,78,0.4,1.1]);
break;
//- thème Moderne
case 4: sessionStorage.topp=JSON.stringify([266,70,0.4,1.1]);
break;
default: ;
}
sessionStorage.initSc=kdocument.getElementById('main').getBoundingClientRect().top;
//---Installation de KI dans iframe
document.body.innerHTML='';
document.head.innerHTML='<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">';
var krabox=document.createElement('IFRAME');
krabox.id="krabox";
krabox.src=(window.location.href);
krabox.style.width="100%";
krabox.style.height="100%";
krabox.style.position='absolute';
krabox.style.border='none';
krabox.style.zIndex="1";
krabox.frameBorder="0";
krabox.display="block";
document.body.style.width='100%';
document.body.style.height='100%';
document.body.style.margin='0px';
document.body.style.padding='0px';
document.body.appendChild(krabox);
//--- boot des fonctions Hécate
document.querySelector("#krabox").addEventListener("load", function() {
//--- Global frame variable
kdocument=document.getElementById('krabox').contentDocument;
sessionStorage.kstyle=parseInt(kdocument.head.querySelector('link').href.split('/')[4]);
sessionStorage.lastd=kdocument.querySelector('#minichat .right-box-title').innerHTML;
var stateObj = { foo: "bar" };
history.replaceState(stateObj, kdocument.title, document.getElementById('krabox').contentWindow.location.href);
//kdocument.addEventListener("scroll", Propylaia);
if(!param.pinup){setInterval(Propylaia, 10);}
else{Trioditis();Propylaia();}
//--- Exécution de Hécate
EnoDisplay();
Soteira();
PhosphorosLite();
Triformis(2);
//---Installation du lecteur (new)
var nPlayer=document.createElement('DIV');
nPlayer.id="player";
//nPlayer.style.width="135px";
//nPlayer.style.height="76px";
nPlayer.style.zIndex="10";
nPlayer.style.position="absolute";
nPlayer.style.top="270px";
nPlayer.style.right="0px";
var divTV=document.createElement('DIV');
divTV.id="hecateTV";
divTV.style.textAlign="right";
divTV.style.width="0px";
divTV.style.height="0px";
divTV.style.zIndex="9";
divTV.appendChild(nPlayer);
//--- YT API
var yScript = document.createElement('script');
yScript.id="yScript";
yScript.innerHTML=ytFunctions(playlistId);
divTV.appendChild(yScript);
function ytFunctions(ytId){
var yCode=`
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player',
{
height: 76,
width: 135,
playerVars:
{
listType:'playlist',
list:'${ytId}',
autoplay:1,
controls:0,
enablejsapi:1,
iv_load_policy:3,
showinfo:0,
modestbranding:1
},
events: {
'onReady': onPlayerReady
}
});
}
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.playVideo();
event.target.setLoop(true);
}
var krabox=document.getElementById('krabox').contentDocument;
krabox.getElementById('play').addEventListener('click',popVideo,false);
function popVideo(){
var pStatus=player.getPlayerState();
if(pStatus!=1){player.playVideo();}else{player.pauseVideo();}
}
krabox.getElementById('playLast').addEventListener('click',previousVideo,false);
function previousVideo(){
player.previousVideo();
}
krabox.getElementById('playNext').addEventListener('click',nextVideo,false);
function nextVideo(){
player.nextVideo();
}
krabox.getElementById('goRng').addEventListener('click',schuffle,false);
sessionStorage.setItem("rng",false);
function schuffle(){
var rng=sessionStorage.getItem("rng");
if(!rng){player.setSchuffle(true);
sessionStorage.setItem("rng",true);}
else{player.setSchuffle(false);
sessionStorage.setItem("rng",false);}
}
`;
return yCode;
}
document.body.appendChild(divTV);
});
}}
//---repositionnements
function Propylaia(){
var initp=JSON.parse(sessionStorage.topp);
var iniSc=JSON.parse(sessionStorage.initSc);
var daplyer=document.getElementById('player');
var fullmc=kdocument.querySelector('#right .right-bigbox');
fullmc.style.position="relative";
fullmc.style.top=initp[1]+"px";
var kscroll=iniSc;
if(!param.pinup){kscroll=kdocument.getElementById('main').getBoundingClientRect().top;}
var tp=initp[0]+kscroll-iniSc;
daplyer.style.top=tp+'px';
var kHeight=kdocument.getElementById('main').clientHeight+kdocument.getElementById('header').clientHeight+kdocument.getElementById('framemenu').clientHeight;
var rposition=0;
var vs = kHeight > document.getElementById('krabox').scrollHeight;
daplyer.style.right=initp[2]+"%";
if(vs){daplyer.style.right=initp[3]+"%";}
}
//--- Installation du Panneau de contrôle vidéo
function EnodiaCtrl(mTitle){
var playLast = kdocument.createElement("BUTTON");
playLast.setAttribute('id','playLast');
playLast.setAttribute('type','button');
playLast.setAttribute('class','pButtons');
playLast.innerHTML="⏮";
var play = kdocument.createElement("BUTTON");
play.setAttribute('id','play');
play.setAttribute('type','button');
play.setAttribute('class','pButtons');
play.innerHTML="⏯";
var playNext = kdocument.createElement("BUTTON");
playNext.setAttribute('id','playNext');
playNext.setAttribute('type','button');
playNext.setAttribute('class','pButtons');
playNext.innerHTML="⏭";
var schuffle = kdocument.createElement("BUTTON");
schuffle.setAttribute('id','goRng');
schuffle.setAttribute('type','button');
schuffle.setAttribute('class','pButtons');
schuffle.innerHTML="<b>⤨</b>";
mTitle.appendChild(playLast);
mTitle.appendChild(play);
mTitle.appendChild(playNext);
mTitle.appendChild(schuffle);
EnodiaCtrlStyle();
}
function EnodiaCtrlStyle(){
var pButtons=kdocument.querySelectorAll('.pButtons');
var fw,fs,mt,w;
switch(csstyle){
//- thème kraland
case 0: {pButtons.forEach(bStyle);
function bStyle(eachOne){
eachOne.style.fontWeight="normal";
eachOne.style.fontSize="13px";
eachOne.style.marginTop="-3px";
eachOne.style.width="21px";
eachOne.style.color="#FABC1A";
}
break;}
//- thème médiéval
case 1: {pButtons.forEach(bStyle);
function bStyle(eachOne){
eachOne.style.fontWeight="normal";
eachOne.style.fontSize="13px";
eachOne.style.marginTop="-5px";
eachOne.style.width="20px";
eachOne.style.color="#CC7766";
}
break;}
//- thème gris
case 2: {pButtons.forEach(bStyle);
function bStyle(eachOne){
eachOne.style.fontWeight="normal";
eachOne.style.fontSize="13px";
eachOne.style.marginTop="-5px";
eachOne.style.width="21px";
eachOne.style.color="#333333";
}
break;}
//- thème standard
case 3: {pButtons.forEach(bStyle);
function bStyle(eachOne){
eachOne.style.fontWeight="normal";
eachOne.style.fontSize="13px";
eachOne.style.marginTop="-3px";
eachOne.style.width="20px";
eachOne.style.color="#665533";
}
break;}
//- thème Moderne
case 4: {pButtons.forEach(bStyle);
function bStyle(eachOne){
eachOne.style.fontWeight="normal";
eachOne.style.fontSize="15px";
eachOne.style.marginTop="0px";
eachOne.style.width="21px";
eachOne.style.color="#3B3B3B";
}
break;}
default: return;
}
}