-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjvc3.user.js
More file actions
36 lines (35 loc) · 33.3 KB
/
jvc3.user.js
File metadata and controls
36 lines (35 loc) · 33.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// ==UserScript==
// @name RisiBank pour JVC
// @namespace risibank.fr
// @description La RisiBank intégrée sur JVC, comme par magie !
// @author RisiBank Admin
// @version 1.3.0
// @website https://risibank.fr
// @homepage https://risibank.fr
// @match https://www.jeuxvideo.com/forums/*
// @match https://www.jeuxvideo.com/recherche/forums/*
// @match https://www.jeuxvideo.com/messages-prives/message.php?folder=*&id*
// @match https://www.jeuxvideo.com/messages-prives/message.php?id=*
// @match https://www.jeuxvideo.com/messages-prives/nouveau.php*
// @match https://www.jeuxvideo.com/forums/message/*
// @match https://m.jeuxvideo.com/forums/create_topic.php*
// @match https://m.jeuxvideo.com/forums/create_message.php*
// @match https://m.jeuxvideo.com/forums/*
// @icon https://risibank.fr/logo.png
// @require https://risibank.fr/downloads/web-api/risibank.js?1.3.0
// @updateURL https://risibank.fr/downloads/userscript/jvc/jvc.user.js
// @downloadURL https://risibank.fr/downloads/userscript/jvc/jvc.user.js
// @run-at document-start
// @connect risibank.fr
// @connect image.noelshack.com
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// @grant GM.addStyle
// @grant GM.setValue
// @grant GM.getValue
// @grant GM.xmlHttpRequest
// @noframes
// ==/UserScript==
(()=>{var e={257:(e,t,n)=>{"use strict";n.r(t),n.d(t,{scriptOptions:()=>s});var i=n(989);class a{static STORAGE_KEY="risibank-options";static OPTIONS=[{name:"enabled",type:"boolean",label:"État du plugin",description:"Activer/désactiver le plugin.",default:()=>!0,hidden:!0},{name:"theme",type:"select",values:[{value:"light",label:"futuriste (light)"},{value:"dark",label:"futuriste (dark)"},{value:"light-old",label:"classique (light)"},{value:"dark-old",label:"classique (dark)"}],label:"Thème de l'interface",description:"Choisir le thème de l'interface de RisiBank. Les thèmes sont les mêmes que sur le site",default:()=>"light"},{name:"defaultTab",type:"select",values:[{value:"search",label:"recherche"},{value:"fav",label:"favoris"},{value:"hot",label:"tendance"},{value:"top",label:"populaire"},{value:"new",label:"récent"},{value:"rand",label:"hasard"}],label:"Onglet par défaut",description:"Choix de l'onglet à afficher par défaut dans l'interface RisiBank",default:()=>"top"},{name:"embedType",type:"select",values:[{value:"iframe",label:"intégré (Haut)"},{value:"iframe-bottom",label:"intégré (Bas)"},{value:"overlay",label:"overlay"}],label:"Mode d'intégration",description:"Choix du monde d'intégration de l'interface RisiBank",default:()=>"iframe"},{name:"embeddedContainerHeight",type:"select",values:[{value:"105px",label:"minuscule"},{value:"165px",label:"petit"},{value:"225px",label:"moyen"},{value:"285px",label:"grand"}],label:"Hauteur fenêtre mode intégré",description:"Choisir la taille de la zone de contenu dans l'interface RisiBank (mode intégré)",default:()=>"165px",activateIf:e=>["iframe","iframe-bottom"].includes(e.embedType)},{name:"mediaSize",type:"select",values:[{value:"sm",label:"petit"},{value:"md",label:"moyen"},{value:"lg",label:"grand"}],label:"Taille des images",description:"Choisir la taille des images dans l'interface RisiBank",default:()=>"sm"},{name:"navbarSize",type:"select",values:[{value:"sm",label:"petit"},{value:"md",label:"moyen"},{value:"lg",label:"grand"}],label:"Taille de la navbar",description:"Choisir la taille de la barre de navigation dans l'interface RisiBank",default:()=>"sm"},{name:"redirectToRisiBank",type:"boolean",label:"Rediriger les stickers vers RisiBank",description:"Lors d'un clic sur un sticker noelshack, rediriger vers RisiBank si le sticker existe plutôt que noelshack",default:()=>!0},{name:"addImageFavoriteButton",type:"boolean",label:"Afficher le bouton favoris",description:"Afficher le bouton favoris lors du survol des images",default:()=>!0},{name:"addTransparency",type:"boolean",label:"Rendre les images transparentes",description:"Remplace les images noelshack par leur version complète (Consomme de la bande passante).",default:()=>!0},{name:"animateGifs",type:"boolean",label:"Animer les GIFs",description:"Anime les GIFs (Consomme de la bande passante).",default:()=>!0},{name:"autoReplaceDeletedImages",type:"boolean",label:"Auto-fix des images supprimées",description:"Remplacer automatiquement les images noelshack supprimées par leur version originale de RisiBank. Cette option ne sera appliquée que si vous avez activé l'option qui rend les images transparente ou anime les GIFs.",values:[!0,!1],default:()=>!0,activateIf:e=>e.addTransparency||e.animateGifs},{name:"embedYoutubeLinks",type:"boolean",label:"Intégration des vidéos youtube",description:"Lecteur intégré YouTube",values:[!0,!1],default:()=>!0},{name:"antiCensorPlugin",type:"boolean",label:"Plugin anti-censure (textuel)",description:"Remplace automatiquement certains mots clefs sensibles d'une manière transparente pour ceux qui ont l'userscript",default:()=>!0},{name:"autoUpdate",type:"boolean",label:"Mise à jour auto",description:"Vérifier automatiquement les mises à jour du script",default:()=>!0},{name:"increaseMessageFormHeight",type:"boolean",label:"Augmenter taille zone message",description:"Augmente la taille par défaut de la zone de message",default:()=>!1},{name:"hideHarassmentPreventionBanner",type:"boolean",label:"Retirer le bandeau anti-harcèlement",description:"Retirer le bandeau de prévention anti-harcèlement du formulaire de message",default:()=>!0},{name:"hideDonateButton",type:"boolean",label:"Masquer bouton donation (🐀)",description:"Masquer le bouton donation",default:()=>!1}];constructor(){this.allOptions=a.OPTIONS,this.options=null}async load(){const e={};for(const t of a.OPTIONS)e[t.name]=t.default();try{const t=JSON.parse(await i.storage.get(a.STORAGE_KEY,"{}"));if(!t)throw new Error("No options found");for(const n in t){const i=t[n],s=a.OPTIONS.find((e=>e.name===n));s&&this.checkOptionValue(s,i)&&(e[n]=i)}}catch(e){console.warn(e)}try{await i.storage.set(a.STORAGE_KEY,JSON.stringify(e))}catch(e){console.warn(e)}this.options=e}checkOptionValue(e,t){return"select"===e.type?e.values.map((e=>e.value)).includes(t):"boolean"===e.type&&"boolean"==typeof t}getOption(e){return this.options[e]}async saveOption(e,t){await this.load();const n=a.OPTIONS.find((t=>t.name===e));if(!n)throw new Error("This option does not exist");if(!this.checkOptionValue(n,t))throw new Error("This value is not valid");this.options[e]=t,await i.storage.set(a.STORAGE_KEY,JSON.stringify(this.options))}}const s=new a},629:(e,t,n)=>{"use strict";n.r(t),n.d(t,{RisiBankJVC:()=>R});var i=n(257),a=n(52);class s{static addInvisibleCharacter(e){return e+""}static associations=Object.fromEntries(decodeURIComponent(window.atob("YWJydXRpJTNCc290JTJDYWh1cmklM0JhYnJpY290JTJDYXJhYmUlM0JmZXVpbGxhZ2UlMkNhdHRhcmQlQzMlQTklM0JtYWxpbiUyQ2F2YWxldXIlM0Jnb3VybWFuZCUyQ2F2b3J0aW4lM0JtYXhpbWlsaWVuJTJDYmFidG91JTNCbW9uc2lldXIlMjBsYWl0JTJDYmFpc2UlM0JzaWZmbG90ZSUyQ2JldXJldHRlJTNCcGFpbiUyMGF1JTIwbGFpdCUyQ2JpdGUlM0JoYXJpY290JTJDYmxhY2tlZCUzQmFzc29tYnJpciUyQ2JvdWdub3VsJTNCY2Fzc291bGV0JTJDYm91Z25vdWxlJTNCdHJhdmFpbGxldXIlMjBzb2NpYWwlMkNjaGlicmUlM0JzdHlsbyUyQ2NoaWVuJTNCZG9nZ28lMkNjb3VpbGxlJTNCZ2Vub3V4JTJDY29ubmFyZCUzQm1hbHBvbGklMkNkZW1ldXIlQzMlQTklM0J0ciVDMyVBOHMlMjBtYWxpbiUyQ2QlQzMlQTliaWxlJTNCbGVudCUyQ2Rlc2NvJTNCbm9uJTIwJUMzJUE5dHVkaWFudCUyQ2VuY3VsZSUzQiVDMyVBOXRvbm5lJTJDZW5jdWwlQzMlQTklM0IlQzMlQTl0b25uJUMzJUE5JTJDZmRwJTNCZmlscyUyQ2YlQzMlQTltaW5pc3RlJTNCbm9lbGlzdGUlMkNmb3V0cmUlM0JmYWlyZSUyQ2d1ZXVsZSUzQmJvdWNoZSUyQ2dsYW5kJTNCY2glQzMlQUFuZSUyQ2p1aWYlM0Jwb21waWVyJTJDbSVDMyVBOHJlJTNCZyVDMyVBOW5pdHJpY2UlMkNtZXJkZSUzQmJvdXNlJTJDbXVzdWxtYW4lM0JyZXN0YXVyYXRldXIlMkNtdXp6JTNCc2VydmV1ciUyQ25pcXVlJTNCYWltZSUyQ3AlQzMlQTlkJUMzJUE5JTNCaGV1cmV1eCUyQ3Bpc3NlJTNCc3Vic3RhbmNlJTIwamF1bmUlMkNwdXRhaW4lMjBkZSUzQnNhY3IlQzMlQTklMkNwdXRhaW4lM0JzYXByaXN0aSUyQ3B1dGUlM0JoYXBwaXN0ZSUyQ3BkJTNCaHVtYWluJTIwYmllbiUyMGVkdXF1JUMzJUE5JTJDcmFjZSUzQmNvbW11bmF1dCVDMyVBOSUyQ3IlQzMlQTlzaWR1JTNCcmVzdGUlMkNzYWxhdWQlM0JnYXJuZW1lbnQlMkNzYWxvcGUlM0JoYXBvZWxpc3RlJTJDc3VjZXVyJTNCZ291cm1ldCUyQ3Ryb3UlMjBkdSUyMGN1bCUzQm1pcyVDMyVBOXJhYmxlJTJDdHJpc28lM0JkeW5hJTJDdHJpc29taXF1ZSUzQmR5bmFtaXF1ZSUyQ3Zpb2wlM0JzYWNyZSUyMGJsZXUlMkN3ZWJlZGlhJTNCYWxsc2FmZSUyQ3lvdXBpbiUzQmpvbGklMjBwaWY=")).split(",").map((e=>e.split(";"))).map((([e,t])=>[e,s.addInvisibleCharacter(t)])));constructor(e){this.model=e}async install(){if(["web","mobile"].includes(this.model.pageType))return;const e=document.querySelectorAll(".bloc-contenu p, .text-enrichi-fmobile p");for(const t of e){let e=t.innerHTML,n=!1;for(const t in s.associations){const i=s.associations[t],[a,o]=[i,t],r=new RegExp(a,"g");e.match(r)&&(e=e.replace(r,o),n=!0)}n&&(t.innerHTML=e)}if(i.scriptOptions.getOption("antiCensorPlugin")){const{submitButtonSelector:e,contentSelector:t}=(0,a.getSelectors)(this.model.pageType);if(!e||!t)return;const n=document.querySelector(e);if(!n)return;n.addEventListener("click",(()=>{const e=document.querySelector(t);for(const t in s.associations){const n=s.associations[t],[i,a]=[t,n],o=new RegExp(`\\b${i}\\b`,"gi");e.value=e.value.replace(o,a)}}))}}}var o=n(989),r=n(738);const{storage:l}=n(989);class c{static STORAGE_KEY="DeviceSeedPlugin_deviceSeed";constructor(e){this.model=e,this.deviceSeed=null}async install(){try{this.deviceSeed=await l.get(c.STORAGE_KEY,"undefined"),"undefined"===this.deviceSeed&&(this.deviceSeed=crypto.randomUUID(),await l.set(c.STORAGE_KEY,this.deviceSeed))}catch(e){console.error(e)}}}class d{static STORAGE_KEY_LAST_UPDATE="AutoUpdatePlugin_lastUpdate";static STORAGE_KEY_IGNORED_VERSION="AutoUpdatePlugin_ignoredVersion";static UPDATE_DELAY=9e5;static UPDATE_LINK="https://risibank.fr/downloads/userscript/jvc/jvc.user.js?from=userscript-jvc";constructor(e){this.model=e,this.deviceSeedPlugin=this.model.getPlugin(c)}getCurrentScriptVersion(){try{return GM.info.script.version}catch(e){try{return GM_info.script.version}catch(e){return"0.0.0"}}}async isVersionIgnored(e){const t=await o.storage.get(d.STORAGE_KEY_IGNORED_VERSION);return!!t&&t===e}async install(){if(!i.scriptOptions.getOption("autoUpdate"))return;const e=await o.storage.get(d.STORAGE_KEY_LAST_UPDATE);if(!e)return void await o.storage.set(d.STORAGE_KEY_LAST_UPDATE,Date.now());if(Date.now()-e<d.UPDATE_DELAY)return;const t=this.getCurrentScriptVersion(),n=(await(0,r.apiGet)(d.UPDATE_LINK+"&version="+t+"&device="+this.deviceSeedPlugin.deviceSeed+"&nocache="+Date.now())).responseText.split("\n").find((e=>e.match(/\/\/ @version (.*)/))).match(/\/\/ @version (.*)/)[1].trim();await o.storage.set(d.STORAGE_KEY_LAST_UPDATE,Date.now()),n!==t&&(await this.isVersionIgnored(n)||(confirm(`Une nouvelle version du script 'RisiBank pour JVC' est disponible (${n}). Voulez-vous l'installer ?`)?document.location.href=d.UPDATE_LINK+"&nocache="+Date.now():confirm("Souhaitez-vous ignorer cette mise à jour ?")&&await o.storage.set(d.STORAGE_KEY_IGNORED_VERSION,n)))}}var p=n(910);class u{constructor(e){this.model=e}async install(){let e=[];e.push(".js-ad-placeholder { display: none !important; }"),i.scriptOptions.getOption("increaseMessageFormHeight")&&e.push("\n .messageEditor__edit { height: 18rem !important; }\n "),await(0,p.installStyles)(e.join("\n"))}}const{scriptOptions:m}=n(257),{loadImage:h}=n(738),{ImageOptimizerPlugin:b}=n(234);class g{constructor(e){this.model=e,this.imageOptimizer=this.model.getPlugin(b)}async install(){let e=Array.from(document.querySelectorAll("img.img-shack"));const t={"^https://www.noelshack.com/(2022|2021|2020|2019)-(\\d+)-(\\d+)-([\\w\\[\\]\\._-]+)$":"https://image.noelshack.com/fichiers/$1/$2/$3/$4","^https://www.noelshack.com/(\\d+)-(\\d+)-(\\d+)-([\\w\\[\\]\\._-]+)$":"https://image.noelshack.com/fichiers/$1/$2/$3/$4"};e=e.map((e=>{for(const n in t){const i=new RegExp(n);e.alt.match(i)&&(e.alt=e.alt.replace(new RegExp(n),t[n]))}return e})),e=e.filter((e=>!!e.alt.match("^https://image.noelshack.com/fichiers/([\\d/]+)/([\\w\\[\\]\\._-]+)$")));let n=0;for(let t of e){const e=++n;t.setAttribute("risibank-id",e);const i=this.imageOptimizer.cached[t.alt];m.getOption("redirectToRisiBank")&&(t.parentElement.href=i?`https://risibank.fr/media/${i.id}-${i.slug}`:"https://risibank.fr/api/v1/medias/by-source?type=jvc&url="+t.alt),t.setAttribute("risibank-original-src",t.src);let a=!1;a=t.alt.match(/\.gif$/)?m.getOption("animateGifs"):m.getOption("addTransparency"),a?i?(t.src=i.thumb,this.addImageButtons(t)):this.replaceImageByFull(e,t.alt):this.addImageButtons(t)}}waitForImageToComplete(e){return e.complete?0!==e.naturalHeight?Promise.resolve(e):Promise.reject(e):new Promise(((t,n)=>{e.addEventListener("load",(()=>{0!==e.naturalHeight?t(e):n(e)})),e.addEventListener("error",(()=>{n(e)}))}))}async replaceImageByFull(e,t){const n=e=>{e.src="https://risibank.fr/cache/medias/0/5/512/51206/thumb.png",e.parentElement.insertAdjacentHTML("beforeend","[Média supprimé]")},i=e=>{e.src=e.getAttribute("risibank-original-src")};let a=document.querySelector(`img[risibank-id="${e}"]`),s=!1;try{await this.waitForImageToComplete(a),s=!0}catch(e){if(!m.getOption("autoReplaceDeletedImages"))return void n(a)}try{if(!s)throw new Error("original image failed");a.style.objectFit="contain",a.src=t,await this.waitForImageToComplete(a),this.addImageButtons(a)}catch(o){if(!m.getOption("autoReplaceDeletedImages"))return void(s?i(a):n(a));try{const n=await h("https://risibank.fr/api/v1/medias/by-source?type=jvc&redirect_to=image&url="+t);a=this.replaceImageByBlob(e,n),this.addImageButtons(a)}catch(e){return void(s?i(a):n(a))}}}replaceImageByBlob(e,t){const n=URL.createObjectURL(t),i=document.querySelector(`img[risibank-id="${e}"]`);return i.setAttribute("src",n),i}addImageButtons(e){m.getOption("addImageFavoriteButton")&&(e.parentElement.style.position="relative",e.parentElement.classList.add("risibank-image-enhancer-link"),e.parentElement.insertAdjacentHTML("beforeend",'\n <div class="risibank-image-enhancer-buttons">\n <button class="add" title="Ajouter à mes favoris">\n ⭐\n </button>\n </div>\n '),e.parentElement.querySelector(".add").addEventListener("click",(t=>{window.open("https://risibank.fr/api/v1/medias/by-source?type=jvc&redirect_to=web-add&url="+e.alt,"_blank"),t.preventDefault(),t.stopPropagation()})))}}var y=n(234);class f{static jvCare(e){const t="0A12B34C56D78E9F";let n="";const i=e.split(" ")[1];for(let e=0;e<i.length;e+=2)n+=String.fromCharCode(16*t.indexOf(i.charAt(e))+t.indexOf(i.charAt(e+1)));return n}static replaceAllJvCare(){const e=document.querySelectorAll(".text-enrichi-forum span.JvCare");for(const t of e){const e=document.createElement("a");e.innerHTML=t.innerHTML;const n=f.jvCare(t.className);e.className="xXx",e.alt=n,e.href=n,e.target="_blank",t.parentNode.replaceChild(e,t)}}constructor(e){this.model=e}async install(){f.replaceAllJvCare()}}class v{constructor(e){this.model=e}async install(){let e=Array.from(document.querySelectorAll("a.xXx"));const t={"^https://risibank.fr/cache/medias/([\\d/]+)/([\\d]+)/(\\w+)\\.(\\w+)$":"https://risibank.fr/media/$2-media-$4","^https://risibank.fr/cache/stickers/d([\\d]+)/([\\d]+)-(\\w+)\\.(\\w+)$":"https://risibank.fr/media/$2-media-$4"};e=e.map((e=>{for(const n in t){const i=new RegExp(n);e.href.match(i)&&(e.href=e.href.replace(new RegExp(n),t[n]))}return e})),e=e.filter((e=>!!e.href.match("^https://risibank.fr/media/(\\d+)-media-(\\w+)$"))),e.forEach((e=>{const t=parseInt(e.href.match("/(\\d+)-media")[1]),n=e.href.match("-media-(\\w+)$")[1],i=this.model.getRisiBankImageUrl(t,n);e.innerHTML=`\n <img class="img-shack" width="68" height="51" src="${i}">\n `}))}}const{scriptOptions:w}=n(257),{waitForFunction:k}=n(52);class T{constructor(e){this.model=e}async install(){const e=Array.from(document.querySelectorAll(".bloc-options-msg .picto-msg-crayon"));for(const t of e)t.addEventListener("click",this.activateForm.bind(this))}async activateForm(e){if(!this.model.getRisiBankIconState())return;const t=e.path[3],n=await k((()=>t.querySelector(".jv-editor-toolbar")),2e3),i=document.createElement("div");i.classList.add("btn-group"),i.innerHTML=`\n <button class="btn btn-jv-editor-toolbar risibank-form-edit-toggle" style="${this.model.getRisiBankIconState()?"":"filter: grayscale(1);"}" type="button" title="Ouvrir l'overlay RisiBank">\n <img src="https://risibank.fr/logo.png" width="14" height="14" style="vertical-align: text-top">\n </button>\n `,n.appendChild(i),t.querySelector(".risibank-form-edit-toggle").addEventListener("click",(e=>this.openRisiBank(t)))}openRisiBank(e){RisiBank.activate({type:"overlay",theme:w.getOption("theme"),defaultTab:w.getOption("defaultTab"),mediaSize:"lg",navbarSize:"lg",onSelectMedia:RisiBank.Actions.addSourceImageLink(e.querySelector("textarea"))})}}class O{constructor(e){this.model=e}async install(){if(!i.scriptOptions.getOption("hideHarassmentPreventionBanner"))return;const e=document.querySelector(".messageEditor__topInfo");e&&(e.style.display="none")}}const{scriptOptions:S}=n(257);class E{constructor(e){this.model=e}async install(){if(!S.getOption("embedYoutubeLinks"))return;let e=Array.from(document.querySelectorAll(".txt-msg a.xXx"));e=e.map((e=>{let t=null,n=null,i=null;return(t=e.href.match(/^https:\/\/youtu.be\/([\w-]+)\?.*t=(\d+)/))?(n=t[1],i=parseInt(t[2])):(t=e.href.match(/^https:\/\/youtu.be\/([\w-]+)/))?(n=t[1],i=0):(t=e.href.match(/^https:\/\/www.youtube.com\/watch\?v=([\w-]+).*\&t=(\d+)/))?(n=t[1],i=parseInt(t[2])):(t=e.href.match(/^https:\/\/www.youtube.com\/watch\?t=(\d+).*\&v=([\w-]+)/))?(n=t[2],i=parseInt(t[1])):(t=e.href.match(/^https:\/\/www.youtube.com\/watch\?v=([\w-]+)/))&&(n=t[1],i=0),n&&(e.setAttribute("data-yt-id",n),e.setAttribute("data-yt-start",i)),e})),e=e.filter((e=>!!e.hasAttribute("data-yt-id"))),e.forEach((e=>{const t=e.getAttribute("data-yt-id"),n=parseInt(e.getAttribute("data-yt-start")),i=document.createElement("p"),a=`\n ${e.outerHTML}\n <iframe\n width="560"\n height="315"\n style="max-width: 100%;"\n src="https://www.youtube.com/embed/${t}?start=${n}"\n title="YouTube video player"\n frameborder="0"\n allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>\n </iframe>\n `;i.innerHTML=a,e.parentNode.replaceChild(i,e)}))}}const{scriptOptions:J}=n(257);class x{constructor(e){this.risibank=e,this.view=new A(this)}open(){this.view.open()}close(){this.view.close()}}class A{constructor(e){this.model=e,this.node=null,this.mount(),this.controller=new M(this.model,this)}mount(){this.node&&this.node.remove(),this.node=document.createElement("div"),this.node.classList.add("risibank-options-panel"),this.node.style.display="none",this.node.style.position="fixed",this.node.style.top="0",this.node.style.left="0",this.node.style.width="100%",this.node.style.height="100%",this.node.style.zIndex="10000000000",this.node.style.padding="20px",this.node.style.textAlign="center",this.node.style.fontSize="16px",this.node.style.overflowY="auto",document.body.appendChild(this.node),this.buildNodeHtml()}buildNodeHtml(){J.getOption("theme").startsWith("dark")?(this.node.style.backgroundColor="rgba(0, 0, 0, 0.9)",this.node.style.color="#cccccc"):(this.node.style.backgroundColor="rgba(255, 255, 255, 0.9)",this.node.style.color="black");let e="";e+="\n <table>\n ";for(const t of J.allOptions)if(!t.hidden&&(!t.activateIf||t.activateIf(J.options))){if(e+=`\n <tr style="height: 28px">\n <td style="width: 20px;">\n <a href="javascript:void(0)" onclick="return false" title="${t.description}" style="border: 1px solid; padding: 1px 5px; border-radius: 3px;">\n ?\n </a>\n </td>\n <td style="width: 350px; text-align: left; padding-left: 10px;" title="${t.description}">\n ${t.label}\n </td>\n `,"boolean"===t.type)e+=`\n <td style="width: 130px;">\n <input\n type="checkbox"\n class="input-on-off"\n id="risibank-${t.name}"\n data-risibank-option-name="${t.name}"\n data-risibank-option-type="${t.type}"\n ${J.getOption(t.name)?'checked=""':""}\n >\n <label for="risibank-${t.name}" class="btn-on-off"></label>\n </td>\n `;else if("select"===t.type){e+=`\n <td style="width: 130px;">\n <select\n data-risibank-option-name="${t.name}"\n data-risibank-option-type="${t.type}"\n value="${J.getOption(t.name)}"\n style="height: 24px; font-size: 12px; width: 100%;"\n >\n `;for(const n of t.values)e+=`\n <option value="${n.value}" ${J.getOption(t.name)===n.value?'selected="selected"':""}>${n.label}</option>\n `;e+="\n </select>\n </td>\n "}e+="\n </tr>\n "}e+="\n </table>\n ",this.node.innerHTML=`\n <div style="position: relative">\n <button class="risibank-options-panel-close" style="position: absolute; top: 0; left: 0; border: 1px solid white; padding: 6px 12px; border-radius: 4px;">Fermer</button>\n <h1 style="margin-bottom: 20px; padding-top: 40px;"><img src="https://risibank.fr/logo.png" height="28" width="28" style="margin-right: 8px; vertical-align: baseline;"> RisiBank JVC</h1>\n <div style="width: 100%; max-width: 500px; margin: 0 auto;">\n ${e}\n </div>\n </div>\n `}open(){this.node.style.display="",document.body.style.overflow="hidden"}close(){this.node.style.display="none",document.body.style.overflow=""}}class M{constructor(e,t){this.model=e,this.view=t,this.bindEvents()}bindEvents(){document.querySelectorAll(".risibank-options-panel-close").forEach((e=>{e.addEventListener("click",(()=>{this.model.close()}))}));const e=Array.from(document.querySelectorAll(".risibank-options-panel input, .risibank-options-panel select"));for(const t of e)t.addEventListener("change",(async()=>{const e=t.dataset.risibankOptionName,n=t.dataset.risibankOptionType;if("boolean"===n)await J.saveOption(e,!!t.checked);else{if("select"!==n)throw new Error("Unknown option type");await J.saveOption(e,t.value)}this.model.risibank.reload(),this.view.buildNodeHtml(),this.bindEvents()}))}}const _=["iframe","iframe-bottom"];class R{constructor(){this.pageType=null,document.location.href.includes("www.jeuxvideo.com/messages-prives/")?this.pageType="mp":"www.jeuxvideo.com"===document.location.hostname?this.pageType="web":this.pageType="mobile",this.view=new I(this),this.components={optionsPanel:new x(this)},this.plugins=[],this.plugins.push(new O(this)),this.plugins.push(new c(this)),this.plugins.push(new f(this)),this.plugins.push(new u(this)),this.plugins.push(new s(this)),this.plugins.push(new v(this)),this.plugins.push(new y.ImageOptimizerPlugin(this)),this.plugins.push(new E(this)),this.plugins.push(new d(this)),this.plugins.push(new T(this)),this.plugins.push(new g(this)),new Promise((async e=>{for(const e of this.plugins)await e.install();e()})).catch((e=>console.error(e)))}getPlugin(e){return this.plugins.find((t=>t instanceof e))}reload(){this.view.init()}getRisiBankImageUrl(e,t){return`https://risibank.fr/cache/medias/${Math.floor(e/1e6)}/${Math.floor(e/1e4)}/${Math.floor(e/100)}/${e}/full.${t}`}getRisiBankIconState(){return"overlay"===i.scriptOptions.getOption("embedType")||i.scriptOptions.getOption("enabled")}}class I{constructor(e){this.model=e,this.init()}mount(){const e=Array.from(document.querySelectorAll(".risibank-cleanup"));for(const t of e)t.remove();if("iframe-bottom"===i.scriptOptions.getOption("embedType")?this.afterIntegrationSelector=".messageEditor__buttonEdit":this.afterIntegrationSelector=".messageEditor__edit",this.textAreaSelector=".messageEditor__edit",this.iframeContainerId="risibank-container",_.includes(i.scriptOptions.getOption("embedType"))&&i.scriptOptions.getOption("enabled"))try{const e=document.querySelector(this.afterIntegrationSelector),t=document.createElement("div");t.id=this.iframeContainerId,t.classList.add("risibank-cleanup"),t.style.height=i.scriptOptions.getOption("embeddedContainerHeight"),"iframe-bottom"===i.scriptOptions.getOption("embedType")?e.parentElement.appendChild(t):e.parentElement.insertBefore(t,e)}catch(e){console.warn("Unable to prepare location for the RisiBank embed",e)}try{const e=document.querySelector(".messageEditor__buttonEdit > .buttonsEditor"),t=document.createElement("div");t.classList.add("risibank-cleanup"),t.classList.add("buttonsEditor__group"),t.innerHTML=`\n <button class="buttonsEditor__button risibank-toggle" style="${this.model.getRisiBankIconState()?"":"filter: grayscale(1);"}" type="button" title="Activer/désactiver le plugin RisiBank">\n <img src="https://risibank.fr/logo.png" width="14" height="14" style="vertical-align: baseline;">\n </button>\n <button class="buttonsEditor__button risibank-open-options" type="button" title="Ouvrir les options du plugin" style="padding-top: 0;">\n ⚙\n </button>\n `,i.scriptOptions.getOption("hideDonateButton")||(t.innerHTML+='\n <button class="buttonsEditor__button" onclick="window.open(\'https://www.buymeacoffee.com/risibank\')" type="button" title="Cette extension a changé ta vie ? Change celle de celui qui a crée cette extension en lui offrant un café" style="padding-top: 0;">\n ☕\n </button>\n '),e.insertBefore(t,e.querySelector(".buttonsEditor__groupPreview"))}catch(e){console.warn("Unable to prepare the location for the RisiBank settings",e)}}init(){this.mount(),_.includes(i.scriptOptions.getOption("embedType"))&&i.scriptOptions.getOption("enabled")&&this.startEmbed(),this.controller=new U(this.model,this)}setReactInputValue(e,t){const n=Object.getOwnPropertyDescriptor(e.__proto__,"value")?.set,i=Object.getPrototypeOf(e),a=Object.getOwnPropertyDescriptor(i,"value")?.set;a&&n!==a?a.call(e,t):n?n.call(e,t):e.value=t,e.dispatchEvent(new Event("input",{bubbles:!0}))}addImageLinkToTextArea({media:e}){const t=document.querySelector(this.textAreaSelector),n=e.source_url,i=t.selectionStart,a=`${t.value[i-1]&&!t.value[i-1].match(/\s/)?" ":""}${n}${void 0!==t.value[i]&&t.value[i].match(/\s/)?"":" "}`;this.setReactInputValue(t,t.value.substring(0,t.selectionStart)+a+t.value.substring(t.selectionStart)),t.focus()}startEmbed(){document.querySelector(`#${this.iframeContainerId}`)&&RisiBank.activate({type:"iframe",container:"#"+this.iframeContainerId,theme:i.scriptOptions.getOption("theme"),defaultTab:i.scriptOptions.getOption("defaultTab"),mediaSize:i.scriptOptions.getOption("mediaSize"),navbarSize:i.scriptOptions.getOption("navbarSize"),onSelectMedia:this.addImageLinkToTextArea.bind(this)})}startOverlay(){RisiBank.activate({type:"overlay",theme:i.scriptOptions.getOption("theme"),defaultTab:i.scriptOptions.getOption("defaultTab"),mediaSize:i.scriptOptions.getOption("mediaSize"),navbarSize:i.scriptOptions.getOption("navbarSize"),onSelectMedia:this.addImageLinkToTextArea.bind(this)})}}class U{constructor(e,t){this.model=e,this.view=t,this.bind()}bind(){const e=Array.from(document.querySelectorAll(".risibank-toggle"));for(const t of e)_.includes(i.scriptOptions.getOption("embedType"))?t.addEventListener("click",(async()=>{await i.scriptOptions.saveOption("enabled",!i.scriptOptions.getOption("enabled")),this.view.init()})):t.addEventListener("click",(async()=>{this.view.startOverlay()}));const t=Array.from(document.querySelectorAll(".risibank-open-options"));for(const e of t)e.addEventListener("click",(()=>{this.model.components.optionsPanel.open()}))}}},234:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ImageOptimizerPlugin:()=>o});var i=n(52);const{storage:a}=n(989),{apiGet:s}=n(738);class o{static STORAGE_KEY_LAST_UPDATE="ImageOptimizerPlugin_lastUpdate";static STORAGE_KEY_DATA="ImageOptimizerPlugin_data";static UPDATE_DELAY=36e5;constructor(e){this.model=e,this.cached={}}async install(){try{this.cached=JSON.parse(await a.get(o.STORAGE_KEY_DATA,"{}"))}catch(e){console.error(e),this.cached={}}this.updateIfNecessary().then((()=>{})).catch((e=>console.error(e)))}async updateIfNecessary(){const e=await a.get(o.STORAGE_KEY_LAST_UPDATE,"0");if(await a.set(o.STORAGE_KEY_LAST_UPDATE,Date.now()),Date.now()-e<o.UPDATE_DELAY)return;const t=[],n=Array.from({length:20}).map(((e,t)=>t+1));for(const e of n)for(const n of["hot"]){const a=JSON.parse((await s(`https://risibank.fr/api/v1/medias/${n}?page=${e}`)).responseText);t.push(...a),await(0,i.wait)(500)}const r={};for(const e of t)r[e.source_url]={id:e.id,slug:e.slug,thumb:e.cache_url.replace("/full.","/thumb.")};await a.set(o.STORAGE_KEY_DATA,JSON.stringify(r))}}},738:(e,t,n)=>{"use strict";function i(){return"undefined"!=typeof GM&&void 0!==GM.xmlHttpRequest?GM.xmlHttpRequest:"undefined"!=typeof GM_xmlhttpRequest?GM_xmlhttpRequest:fetch}function a(e){return new Promise(((t,n)=>{i()({url:e,method:"GET",onload:e=>{e.status<200||e.status>=300?n(e.statusText):t(e)},onerror:e=>{n(e)}})}))}function s(e){return new Promise(((t,n)=>{i()({url:e,method:"GET",responseType:"blob",onload:e=>{e.status<200||e.status>=300?n(e.statusText):t(e.response)},onerror:e=>{n(e)}})}))}n.r(t),n.d(t,{apiGet:()=>a,loadImage:()=>s})},989:(e,t,n)=>{"use strict";n.r(t),n.d(t,{storage:()=>i});const i=new class{constructor(){this.identify()}identify(){return"undefined"!=typeof GM_getValue?(this.get=async(e,t)=>GM_getValue(e,t),void(this.set=async(e,t)=>GM_setValue(e,t))):"object"==typeof GM?(this.get=async(e,t)=>GM.getValue(e,t),void(this.set=async(e,t)=>GM.setValue(e,t))):"undefined"!=typeof localStorage?(this.get=async(e,t)=>localStorage.getItem(e)||t,void(this.set=async(e,t)=>localStorage.setItem(e,t))):"undefined"!=typeof sessionStorage?(this.get=async(e,t)=>sessionStorage.getItem(e)||t,void(this.set=async(e,t)=>sessionStorage.setItem(e,t))):(this.get=async(e,t)=>t,void(this.set=async(e,t)=>{console.warn("Unable to store data in any storage")}))}}},910:(e,t,n)=>{"use strict";n.r(t),n.d(t,{installDefaultStyles:()=>s,installStyles:()=>a});var i=n(52);const a=async e=>{try{GM_addStyle(e)}catch(t){const n=await(0,i.waitForFunction)((()=>document.querySelector("head")),5e3);n||console.error("RisiBank: Unable to load styles");const a=document.createElement("style");a.appendChild(document.createTextNode(e)),n.appendChild(a)}},s=async()=>{await a('\n<style type="text/css">\n /* Hide empty ad banner */\n .js-ad-placeholder { display: none !important; }\n\n /* Stop message flash */\n /*\n #forum-main-col .bloc-message-forum-anchor:target+.bloc-message-forum:not(.seen) {\n background-color: transparent !important;\n }\n */\n \n /* Fix message column size: Fix min-width too large on desktop version from 1480px to 1200px */\n @media (min-width: 1200px) {\n .layout {\n --grid-template-columns: 1fr 49rem 24.5rem 1fr;\n }\n }\n\n /* Image enhancer */\n .risibank-image-enhancer-buttons {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 20px;\n display: none;\n }\n .risibank-image-enhancer-link:hover .risibank-image-enhancer-buttons {\n display: flex;\n }\n .risibank-image-enhancer-buttons button {\n flex-grow: 1;\n font-size: 10px;\n border: none;\n }\n .risibank-image-enhancer-buttons button.copy-source {\n background-color: #8860d0;\n }\n .risibank-image-enhancer-buttons button.copy-source:hover {\n background-color: #7452b1;\n }\n .risibank-image-enhancer-buttons button.add {\n background-color: #5680e9;\n }\n .risibank-image-enhancer-buttons button.add:hover {\n background-color: #496dc6;\n }\n</style>\n')}},52:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getSelectors:()=>s,wait:()=>i,waitForFunction:()=>a});const i=e=>new Promise((t=>setTimeout(t,e))),a=async(e,t)=>{const n=(t||2e3)/50;let a=e(),s=0;for(;!a&&s<n;)a=e(),await i(50),++s;return a};function s(e){let t;if("web"===e)t="button.postMessage";else if("mp"===e)t="button.js-post-message";else{if("mobile"!==e)return null;t="button.postMessage"}return{submitButtonSelector:t,contentSelector:".messageEditor__edit"}}}},t={};function n(i){var a=t[i];if(void 0!==a)return a.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{const{installDefaultStyles:e}=n(910),{scriptOptions:t}=n(257),{RisiBankJVC:i}=n(629),{waitForFunction:a}=n(52);(async function(){await t.load(),await e(),window.addEventListener("load",(async e=>{await a((()=>document.body)),new i}),!1)})().then((()=>console.log("RisiBankJVC is ready")))})()})();