User:OldBee/LiveRC.js/2.0.js

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
if(typeof(LiveRC)==="undefined"){

window.LiveRC = {
  texts : {
    "SpecialpageName"       : "LiveRC",
    "SpecialpageNameH"      : "$1 — Wikipédia",
    "HideUserText"          : "Masquer",
    "HideUserTip"           : "Masquer l’utilisateur",
    "UnHideUserText"        : "Ne plus masquer",
    "UnHideUserTip"         : "Ne plus masquer l’utilisateur",
    "WatchUserText"         : "Suivre",
    "WatchUserTip"          : "Suivre l’utilisateur",
    "UnWatchUserText"       : "Ne plus suivre",
    "UnWatchUserTip"        : "Ne plus suivre l’utilisateur",
    "VersionDiff"           : "Vous utilisez la version $1 de LiveRC, qui est obsolète. Veuillez recharger le cache de votre navigateur pour utiliser la dernière version : $2.",

    "TopLinksFullscreenOnIconTip"    : "Afficher en plein écran",
    "TopLinksFullscreenOffIconTip"   : "Quitter le mode plein écran",
    "TopLinksTchatIconTip"           : "Ouvrir la fenêtre de tchat",
    "TopLinksOptionsIconTip"         : "Modifier les paramètres",
    "TopLinksRCListIconTip"          : "Afficher la liste des RC",
    "TopLinksPreviewDiffIconTip"     : "Afficher la prévisualisation d’un diff",
    "TopLinksPreviewPageIconTip"     : "Afficher la prévisualisation d’une page",
    "TopLinksPreviewUserIconTip"     : "Afficher la prévisualisation d’un utilisateur",
    "TopLinksSpecialLogsIconTip"     : "Afficher la prévisualisation des listes de suivi spéciales",
  },
  images : {
    "TopLinksFullscreenOnIcon"    : "thumb/5/5a/LiveRC_ControlIcon_fullscreen_on.png/75px-LiveRC_ControlIcon_fullscreen_on.png",
    "TopLinksFullscreenOffIcon"   : "thumb/d/df/LiveRC_ControlIcon_fullscreen_off.png/75px-LiveRC_ControlIcon_fullscreen_off.png",
    "TopLinksTchatIcon"           : "thumb/e/e8/LiveRC_ControlIcon_Tchat.png/75px-LiveRC_ControlIcon_Tchat.png",
    "TopLinksOptionsIcon"         : "thumb/7/7d/LiveRC_ControlIcon_Options.png/75px-LiveRC_ControlIcon_Options.png",
    "TopLinksRCListIcon"          : "thumb/2/28/LiveRC_ControlIcon_RClist.png/75px-LiveRC_ControlIcon_RClist.png",
    "TopLinksPreviewDiffIcon"     : "thumb/3/33/LiveRC_ControlIcon_Preview_diff.png/75px-LiveRC_ControlIcon_Preview_diff.png",
    "TopLinksPreviewPageIcon"     : "thumb/0/01/LiveRC_ControlIcon_Preview_page.png/75px-LiveRC_ControlIcon_Preview_page.png",
    "TopLinksPreviewUserIcon"     : "thumb/c/ce/LiveRC_ControlIcon_Preview_user.png/75px-LiveRC_ControlIcon_Preview_user.png",
    "TopLinksSpecialLogsIcon"     : "thumb/4/4f/LiveRC_ControlIcon_Special_Log_Lists.png/75px-LiveRC_ControlIcon_Special_Log_Lists.png",
  },
  styles : {

  },
  params : {
// editable
    "FullScreenStart" : false,
    "ImageURL"        : "//upload.wikimedia.org/wikipedia/commons/",
// non editable
    "Version" : "2.0.0",
    "SpecialpageName" : "LiveRC",
    "UsercustompageName" : "/LiveRCparams.js",
    "ScriptpageName" : "User:OldBee/LiveRC.js",
    "LangpagesName" : "User:OldBee/LiveRC.js/i18n/$lang.js",
    "LaunchCondition" : false,
    "TargetedLI" : "n-recentchanges",
    "FullScreen" : false,
    "ActualStyleTag" : false,
    "Debug" : true,
    "APILimit" : 500,
    "LaunchProcess" : [],
    "ForeignWikisMap" : [],
    "SelectedForeignWikis" : [],
  },
  functions : {
// --------------------------------------------------------------------------------------------------------------- Fonctions diverses
    debug : function(text){
      if(!LiveRC.params.Debug || !text || ["string","number"].indexOf(typeof(text))===-1) return;
      console.info(text);
    },
    createIcon : function(type, options){
      var img = document.createElement("img");
      img.src = LiveRC.params.ImageURL + LiveRC.images[type];
      img.className = (options && options.class ? options.class : type );
      img.alt = (options && options.alt ? options.alt : type );
      return img;
    },
    createLink : function(page, options){
      var link = document.createElement("a");
      link.href = (options && options.href ? options.href : mw.util.getUrl(page));
      link.title = (options && options.title ? options.title : page );
      link.innerHTML = ((options && typeof(options.text)==="string") ? options.text : page );
      if(options && options.class) link.className = options.class;
      return link;
    },
// --------------------------------------------------------------------------------------------------------------- Initialisation page spéciale
    initSpecialPageProcess : function(){
      LiveRC.params.LaunchProcess = [
        {functions:"initSpecialPage",                             condition:true  }, // OK
        {functions:"setInterfaceLanguage",                        condition:true  },
        {functions:"getVersion",                                  condition:true  }, // OK
        {functions:"getSiteInfos",                                condition:true  },
        {functions:"getSelectedForeignSitesInfos",                condition:true  },
        {functions:"getCurrentUserInfos",                         condition:true  },
        {functions:"getCurrentUserInfosOnSelectedForeignSites",   condition:true  },
        {functions:"getUsersInGroups",                            condition:true  },
        {functions:"getUsersInGroupsOnSelectedForeignSites",      condition:true  },
        {functions:"getWatchlist",                                condition:true  }, // only for hidden users & pages and watched users. global storage at meta watchlist or local storage != for each wiki ?
        {functions:"loadBlocks",                                  condition:true  },
        {functions:"loadUsersInCats",                             condition:true  },
        {functions:"buildReportCreateReasons",                    condition:true  },
        {functions:"buildInterface",                              condition:true  },



// TODO //


//        {functions:"isReady", condition:true },
      ];

      LiveRC.functions.nextStepOfLaunchingProcess();
    },
    nextStepOfLaunchingProcess : function(){
      var Process = LiveRC.params.LaunchProcess;
      var alreadydone = 0;
      var total = Process.length;
      for(var a=0,l=Process.length;a<l;a++){
        var ThisProcess = Process[a];
        var launched = ThisProcess.launched;
        if(launched === true){
          alreadydone++;
          continue;
        }
        var condition = ThisProcess.condition;
        if(typeof(condition)!=="undefined" && !condition){
          total--;
          continue;
        }
        var functions = ThisProcess.functions;
        var Type = typeof(functions);
        if(Type==="string" && typeof(LiveRC.functions[functions])==="function"){
          LiveRC.params.LaunchProcess[a].launched = true;
          LiveRC.functions.debug(functions);
          LiveRC.functions.updateProgressBar(Math.floor(100*(alreadydone/total)));
          LiveRC.functions[functions]();
          return;
        }else if(Type==="object"){
          LiveRC.params.LaunchProcess[a].launched = true;
          LiveRC.functions.updateProgressBar(Math.floor(100*(alreadydone/total)));
          for(var f=0,flen=functions.length;f<flen;f++){
            var ThisFunction = functions[f];
            LiveRC.functions.debug(ThisFunction);
            if(typeof(ThisFunction)==="string" && typeof(LiveRC.functions[ThisFunction]) === "function") LiveRC.functions[ThisFunction]();
          }
          return;
        }else{
          total--;
          continue;
        }
      }
      LiveRC.functions.updateProgressBar(100);
    },
    updateProgressBar : function(val){
      var ProgressBar = document.getElementById("ProgressBar");
      if(ProgressBar) ProgressBar.style.width = val+"%";
      var ProgressBarLabel = document.getElementById("ProgressBarLabel");
      if(ProgressBarLabel) ProgressBarLabel.innerHTML = val+"%";
      LiveRC.functions.debug(val+"%");
    },
    initSpecialPage : function(){
      LiveRC.params.FullScreen = LiveRC.params.FullScreenStart;
      var Title = document.getElementsByTagName('title')[0];
      var TitleH = document.getElementById('firstHeading');
      if(!TitleH) TitleH = document.getElementById('section_0');
      if(!TitleH) TitleH = document.getElementsByTagName('h1')[0];
      var Content = document.getElementById('mw-content-text');
      if(!Title || !TitleH || !Content) return;
      $(document.body).removeClass("mw-invalidspecialpage");
      Title.innerHTML = LiveRC.texts.SpecialpageNameH.split("$1").join(LiveRC.texts.SpecialpageName);
      TitleH.innerHTML = LiveRC.texts.SpecialpageName + '<span id="TestedVersion">'+LiveRC.params.Version+'</span>';
      while(Content.firstChild){ Content.removeChild(Content.firstChild); }
      var NormalWrapper = document.createElement("div");
      NormalWrapper.id = "NormalWrapper";
      while(document.body.firstChild){ NormalWrapper.appendChild(document.body.firstChild); }
      document.body.appendChild(NormalWrapper);
      var FullScreen = document.body.appendChild(document.createElement("div"));
      FullScreen.id = "LiveRCBoard_fullscreen";
      var Normal = Content.appendChild(document.createElement("div"));
      Normal.id = "LiveRCBoard_normal";
      if(LiveRC.params.FullScreenStart) NormalWrapper.style.display ="none";
      else FullScreen.style.display ="none";
      LiveRC.functions.buildSpecialPage( (LiveRC.params.FullScreen ? FullScreen : Normal) );
      LiveRC.functions.nextStepOfLaunchingProcess();
    },
    toggleFullscreen : function(){
      var FullScreen = document.getElementById("LiveRCBoard_fullscreen");
      var Normal = document.getElementById("LiveRCBoard_normal");
      var NormalWrapper = document.getElementById("NormalWrapper");
      var Nodes = (LiveRC.params.FullScreen ? [FullScreen, Normal, FullScreen, NormalWrapper] : [Normal, FullScreen, NormalWrapper, FullScreen]);
      while(Nodes[0].firstChild){ Nodes[1].appendChild(Nodes[0].firstChild) }
      Nodes[2].style.display = "none";
      Nodes[3].style.display = "";
      LiveRC.params.FullScreen = !LiveRC.params.FullScreen;
    },
    buildSpecialPage : function(BoardContent){
      var TopLinks = BoardContent.appendChild(document.createElement('div'));
      TopLinks.id = "TopLinks";
      TopLinks.style.display = "none";

      var PreviewDiffContainer = BoardContent.appendChild(document.createElement('div'));
      PreviewDiffContainer.id = "PreviewDiffContainer";
      PreviewDiffContainer.innerHTML = "Prévisualisation diff";

      var PreviewPageContainer = BoardContent.appendChild(document.createElement('div'));
      PreviewPageContainer.id = "PreviewPageContainer";
      PreviewPageContainer.innerHTML = "Prévisualisation page";

      var PreviewUserContainer = BoardContent.appendChild(document.createElement('div'));
      PreviewUserContainer.id = "PreviewUserContainer";
      PreviewUserContainer.innerHTML = "Prévisualisation utilisateur";

      var RCContainer = BoardContent.appendChild(document.createElement('div'));
      RCContainer.id = "RCContainer";

      var RCControlPanel = RCContainer.appendChild(document.createElement('div'));
      RCControlPanel.id = "RCControlPanel";
      RCControlPanel.innerHTML = "Contrôle des lignes RC";

      var RCList = RCContainer.appendChild(document.createElement('div'));
      RCList.id = "RCList";
      RCList.innerHTML = "Lignes RC";

      var LogListsContainer = BoardContent.appendChild(document.createElement('div'));
      LogListsContainer.id = "LogListsContainer";
      LogListsContainer.innerHTML = "Listes de suivi spéciales";

      var OptionsContainer = BoardContent.appendChild(document.createElement('div'));
      OptionsContainer.id = "OptionsContainer";
      OptionsContainer.innerHTML = "Options";
      

      var ProgressBarContainer = BoardContent.appendChild(document.createElement('div'));
      ProgressBarContainer.id = "ProgressBarContainer";
      var ProgressBar = ProgressBarContainer.appendChild(document.createElement('div'));
      ProgressBar.id = "ProgressBar";
      var ProgressBarLabel = BoardContent.appendChild(document.createElement('div'));
      ProgressBarLabel.id = "ProgressBarLabel";
    },
    getVersion : function(){
      var api = new mw.ForeignApi("https://www.wikidata.org/w/api.php");
      api.get({
        action : 'wbgetentities',
        ids    : 'Q7027060',
        props  : 'claims'
      }).done(function(data){
        var version = data.entities["Q7027060"].claims["P348"][0].mainsnak.datavalue.value;
        console.log(version);
        var VersionSpan = document.getElementById("TestedVersion");
        if(VersionSpan){
          var TestedVersion = VersionSpan.innerHTML;
          var validatedVersion = '<span style="font-weight:bold;color:green;">'+LiveRC.params.Version+'</span>';
          var newVersion = '<br><span style="font-weight:bold;color:#d33;" >'+LiveRC.texts.VersionDiff.split("$1").join(TestedVersion).split("$2").join(version)+'</span>';
          if(TestedVersion === version){
            VersionSpan.innerHTML = validatedVersion;
          }else{
            VersionSpan.innerHTML = newVersion;
          }
        }
        LiveRC.functions.nextStepOfLaunchingProcess();
      });
    },
    getSiteInfos : function(){

            // TODO //



        LiveRC.functions.nextStepOfLaunchingProcess();
    },
    getSelectedForeignSitesInfos : function(){

            // TODO //



        LiveRC.functions.nextStepOfLaunchingProcess();
    },
    getCurrentUserInfos : function(){

            // TODO //



        LiveRC.functions.nextStepOfLaunchingProcess();
    },
   getCurrentUserInfosOnSelectedForeignSites : function(){

            // TODO //



        LiveRC.functions.nextStepOfLaunchingProcess();
    },
   getUsersInGroups : function(){

            // TODO //



        LiveRC.functions.nextStepOfLaunchingProcess();
    },
   getUsersInGroupsOnSelectedForeignSites : function(){

            // TODO //



        LiveRC.functions.nextStepOfLaunchingProcess();
    },
   getWatchlist : function(){

            // TODO //



        LiveRC.functions.nextStepOfLaunchingProcess();
    },
   loadBlocks : function(){

            // TODO //



        LiveRC.functions.nextStepOfLaunchingProcess();
    },
   loadUsersInCats : function(){

            // TODO //



        LiveRC.functions.nextStepOfLaunchingProcess();
    },
    buildReportCreateReasons : function(){

            // TODO //



        LiveRC.functions.nextStepOfLaunchingProcess();
    },
    buildInterface : function(){

      LiveRC.functions.buildTopLinks();

            // TODO //

      LiveRC.functions.nextStepOfLaunchingProcess();
    },
    buildTopLinks : function(){
      var TopLinks = document.getElementById("TopLinks");
      var TopLinksContent = TopLinks.appendChild(document.createElement('div'));
      TopLinksContent.id = "TopLinksContent";
      var TopLinksIcons = ["FullscreenOff", "FullscreenOn", "Tchat", "RCList", "PreviewDiff", "PreviewPage", "PreviewUser", "SpecialLogs", "Options"];
      for(var a=0,l=TopLinksIcons.length;a<l;a++){
        var icon = TopLinksIcons[a];
        var type = "TopLinks"+icon+"Icon";
        var Tip = "TopLinks"+icon+"IconTip";
        var Link = TopLinksContent.appendChild(LiveRC.functions.createLink("",{text:"",title:LiveRC.texts[Tip],href:"javascript:;"}));
        Link.innerHTML = "";
        Link.className = type+"Link";
        Link.appendChild(LiveRC.functions.createIcon(type));
        if(["FullscreenOn","FullscreenOff"].indexOf(icon) !==-1) Link.onclick = function(){ LiveRC.functions.toggleFullscreen(); }
        if(icon == "Tchat") Link.onclick = function(){ return false; }
        if(icon == "RCList")  Link.onclick = function(){ LiveRC.functions.toggleView("RCListShown"); }
        if(icon == "Options") Link.onclick = function(){ LiveRC.functions.toggleView("OptionsShown"); }
        if(icon == "PreviewDiff") Link.onclick = function(){ LiveRC.functions.toggleView("PreviewDiffShown"); }
        if(icon == "PreviewPage") Link.onclick = function(){ LiveRC.functions.toggleView("PreviewPageShown"); }
        if(icon == "PreviewUser") Link.onclick = function(){ LiveRC.functions.toggleView("PreviewUserShown"); }
        if(icon == "SpecialLogs") Link.onclick = function(){ LiveRC.functions.toggleView("SpecialLogsShown"); }
      }
    },
    toggleView : function(shownclass){
      var classes = ["RCListShown","PreviewDiffShown","PreviewPageShown","PreviewUserShown","SpecialLogsShown","OptionsShown"];
      var B = $(document.body);
      for(var a=0,l=classes.length;a<l;a++){
        var thisClass = classes[a];
        if(thisClass == shownclass) B.addClass(thisClass);
        else B.removeClass(thisClass);
      }
    },
    isReady : function(){
      var ProgressBarContainer = document.getElementById("ProgressBarContainer");
      if(ProgressBarContainer) ProgressBarContainer.parentNode.removeChild(ProgressBarContainer);
      var ProgressBarLabel = document.getElementById("ProgressBarLabel");
      if(ProgressBarLabel) ProgressBarLabel.parentNode.removeChild(ProgressBarLabel);
      var TopLinks = document.getElementById("TopLinks");
      if(TopLinks) TopLinks.style.display = "";
      LiveRC.functions.toggleView("RCListShown");
      LiveRC.functions.nextStepOfLaunchingProcess();
    },
// --------------------------------------------------------------------------------------------------------------- Liens dans le panneau de gauche
    getLiveRCLI : function(){
      var oldLI = document.getElementById("n-liverc");
      if(oldLI) return oldLI;
      var Target = document.getElementById(LiveRC.params.TargetedLI);
      if(!Target) return;
      oldLI = Target.parentNode.insertBefore(document.createElement('li'), Target.nextSibling);
      oldLI.id = "n-liverc";
      return oldLI;
    },
    getLiveRCSubLI : function(){
      var LI = LiveRC.functions.getLiveRCLI(); 
      var UL = LI.getElementsByTagName('ul')[0];
      if(!UL){
        UL = LI.appendChild(document.createElement('ul'))
      }
      return UL.appendChild(document.createElement('li'));
    },
    hideUser : function(username, unhide, callback){
      var P = "LiveRC:Hide:"+username, api = new mw.Api();
      if(unhide) api.unwatch(P).done(function(data){ if(typeof(callback)==="function") callback(data); });
      else api.watch(P).done(function(data){ if(typeof(callback)==="function") callback(data); });;
    },
    followUser : function(username, unwatch, callback){
      var P = "LiveRC:Watch:"+username, api = new mw.Api();
      if(unwatch) api.unwatch(P).done(function(data){ if(typeof(callback)==="function") callback(data); });
      else api.watch(P).done(function(data){ if(typeof(callback)==="function") callback(data); });
    },
    hideThisUser : function(unhide){
      var username = mw.config.get('wgTitle').split("/")[0];
      var Link = document.getElementById("HideUserLink");
      if(!Link) return;
      LiveRC.functions.hideUser(username, unhide, LiveRC.functions.toggleHideUserLink);
      
    },
    followThisUser : function(unwatch){
      var username = mw.config.get('wgTitle').split("/")[0];
      var Link = document.getElementById("WatchUserLink");
      if(!Link) return;
      LiveRC.functions.followUser(username, unwatch, LiveRC.functions.toggleFollowUserLink);      
    },
    addHideUserLink : function(){
      var T = LiveRC.texts;
      var LI = LiveRC.functions.getLiveRCSubLI();
      LI.style.display = "none";
      var User = mw.config.get('wgTitle').split("/")[0];
      var HLink = LI.appendChild(LiveRC.functions.createLink("",{text:T.HideUserText,title:T.HideUserTip}));
      HLink.href = "javascript:LiveRC.functions.hideThisUser(false);";
      HLink.id = "HideUserLink";
      var UHLink = LI.appendChild(LiveRC.functions.createLink("",{text:T.UnHideUserText,title:T.UnHideUserTip}));
      UHLink.href = "javascript:LiveRC.functions.hideThisUser(true);";
      UHLink.id = "UnHideUserLink";
      $.ajax({url:mw.util.wikiScript('api'),data:{format:'json',action:'query',list:'watchlistraw',wrlimit:1,wrnamespace:0,wrfromtitle:('LiveRC:Hide:'+User)},dataType:'json'
      }).then(function(data){        
        var WL = data.watchlistraw[0];
        $(document.body).addClass("user" + (WL ? "" : "un") + "hidden");
        LI.style.display = "";
      });
    },
    toggleHideUserLink : function(data){
      if($(document.body).hasClass("userhidden")){
        $(document.body).removeClass("userhidden");
        $(document.body).addClass("userunhidden");
      }else{
        $(document.body).removeClass("userunhidden");
        $(document.body).addClass("userhidden");
      } 
    },
    addFollowUserLink : function(){
      var T = LiveRC.texts;
      var LI = LiveRC.functions.getLiveRCSubLI();
      LI.style.display = "none";
      var User = mw.config.get('wgTitle').split("/")[0];
      var WLink = LI.appendChild(LiveRC.functions.createLink("",{text:T.WatchUserText,title:T.WatchUserTip}));
      WLink.href = "javascript:LiveRC.functions.followThisUser(false);";
      WLink.id = "WatchUserLink";
      var UWLink = LI.appendChild(LiveRC.functions.createLink("",{text:T.UnWatchUserText,title:T.UnWatchUserTip}));
      UWLink.href = "javascript:LiveRC.functions.followThisUser(true);";
      UWLink.id = "UnWatchUserLink";
      $.ajax({url:mw.util.wikiScript('api'),data:{format:'json',action:'query',list:'watchlistraw',wrlimit:1,wrnamespace:0,wrfromtitle:('LiveRC:Watch:'+User)},dataType:'json'
      }).then(function(data){        
        var WL = data.watchlistraw[0];
        $(document.body).addClass("user" + (WL ? "" : "un") + "watched");
        LI.style.display = "";
      });
    },
    toggleFollowUserLink : function(data){
      if($(document.body).hasClass("userwatched")){
        $(document.body).removeClass("userwatched");
        $(document.body).addClass("userunwatched");
      }else{
        $(document.body).removeClass("userunwatched");
        $(document.body).addClass("userwatched");
      } 
    },
    addLiveRCLink : function(){
      var LI = LiveRC.functions.getLiveRCLI();
      LI.appendChild(LiveRC.functions.createLink((mw.config.get('wgFormattedNamespaces')[-1]+":"+LiveRC.params.SpecialpageName),{text:LiveRC.texts.SpecialpageName}));
    },
// --------------------------------------------------------------------------------------------------------------- Lancement
    launchUsing : function(using, func){
      $.when.apply( null, $.map(using, function ( url ) {
        return $.ajax({ url: url, dataType: 'script', cache: true });
      })).done(func);
    },
    launch : function(){
      var UserPage = mw.util.getUrl(mw.config.get('wgFormattedNamespaces')[2]+":"+mw.config.get('wgUserName')+LiveRC.params.UsercustompageName, {'action':'raw','ctype':'text/javascript'});
      LiveRC.functions.launchUsing([ UserPage ], function(){
        var Cond = LiveRC.params.LaunchCondition;
        LiveRC.functions.setCSS();
        if(Cond === 1) LiveRC.functions.initSpecialPageProcess();
        if(Cond !== 1) LiveRC.functions.addLiveRCLink();
        if(Cond === 3){
          LiveRC.functions.addFollowUserLink();
          LiveRC.functions.addHideUserLink();
        }
      });
    },
    getLaunchCondition : function(){
      var wgTitle = mw.config.get('wgTitle');
      var wgAction = mw.config.get('wgAction');
      var wgNamespaceNumber = mw.config.get('wgNamespaceNumber');
      var wgCanonicalSpecialPageName = mw.config.get('wgCanonicalSpecialPageName');
      var wgUserName = mw.config.get('wgUserName');
      var LaunchCondition = false;
      if(wgNamespaceNumber == -1 && wgTitle == LiveRC.params.SpecialpageName ) LaunchCondition = 1;  // -----------------------Special page
      else if(wgNamespaceNumber == 2 && wgTitle == (wgUserName +LiveRC.params.UsercustompageName) ) LaunchCondition = 2;  //---User LiveRC custom page (edit custom)
      else if([2,3].indexOf(wgNamespaceNumber) !== -1) LaunchCondition = 3;  // -----------------------------------------------User page (follow/hide user)
      else  LaunchCondition = 99;  // -----------------------------------------------------------------------------------------Anywhere else
      LiveRC.params.LaunchCondition = LaunchCondition;
      LiveRC.functions.debug("LiveRC launch condition = "+LaunchCondition);
      return LaunchCondition; 
    },
// --------------------------------------------------------------------------------------------------------------- Styles CSS
    getCSSstyle : function(stylename) { 
      if(typeof(LiveRC.params.DEFAULTstyles[stylename])==="undefined") return "";
      if(typeof(LiveRC.styles[stylename])==="undefined") return "";
      return LiveRC.styles[stylename];
    },
    setCSS : function(){ 
      var CSS = LiveRC.functions.getCSSstyle;   
      if(LiveRC.params.ActualStyleTag){
        LiveRC.params.ActualStyleTag.parentNode.removeChild(LiveRC.params.ActualStyleTag);
      }
      var NewStyles = ""
        + ".userhidden #HideUserLink { display:none; }"
        + ".userunhidden #UnHideUserLink { display:none; }"
        + ".userwatched #WatchUserLink { display:none; }"
        + ".userunwatched #UnWatchUserLink  { display:none; }"

        + "#LiveRCBoard_fullscreen .TopLinksFullscreenOnIconLink, #LiveRCBoard_normal .TopLinksFullscreenOffIconLink { display:none; }"


        + "#LiveRCBoard_fullscreen #TopLinks { position:fixed;top:0;right:0;width:5px;height:100%;display:flex;justify-content:center;align-items:center;transition:width 1s; }"
        + "#LiveRCBoard_fullscreen #TopLinksContent { display:flex;flex-direction:column;padding:6px;border:1px solid black;border-right:none;background-color:white;border-bottom-left-radius:1.5em;border-top-left-radius:1.5em;position:relative;left:66px;transition:left 1s; }"
        + "#LiveRCBoard_fullscreen #TopLinksContent img { width:50px;border-radius:1em;border:2px solid transparent; }"
        + "#LiveRCBoard_fullscreen #TopLinksContent a { margin-top:0.5em; }"
        + "#LiveRCBoard_fullscreen #TopLinksContent a.TopLinksRCListIconLink { margin-top:2em; }"
        + "#LiveRCBoard_fullscreen #TopLinksContent a:first-of-type { margin-top:0; }"
        + "#LiveRCBoard_fullscreen #TopLinks:hover { width:66px;transition:width 1s; }"
        + "#LiveRCBoard_fullscreen #TopLinks:hover #TopLinksContent { left:0px;transition:left 1s; }"

        + "#LiveRCBoard_normal #TopLinks { text-align:center; }"
        + "#LiveRCBoard_normal #TopLinksContent { display:inline-block; }"
        + "#LiveRCBoard_normal #TopLinksContent img { width:50px;border-radius:1em;border:2px solid transparent; }"
        + "#LiveRCBoard_normal #TopLinksContent a { margin-right:0.5em; }"
        + "#LiveRCBoard_normal #TopLinksContent a.TopLinksRCListIconLink { margin-left:1.5em; }"
        + "#LiveRCBoard_normal #TopLinksContent a:last-of-type { margin-right:0; }"


        + "#RCContainer { display:none; }"
        + ".TopLinksRCListIcon { border-color:red !important; }"
        + ".RCListShown #RCContainer { display:block; }"
        + ".RCListShown .TopLinksRCListIcon { border-color:green !important; }"

        + "#PreviewDiffContainer { display:none; }"
        + ".TopLinksPreviewDiffIcon { border-color:red !important; }"
        + ".PreviewDiffShown #PreviewDiffContainer { display:block; }"
        + ".PreviewDiffShown .TopLinksPreviewDiffIcon { border-color:green !important; }"

        + "#PreviewPageContainer { display:none; }"
        + ".TopLinksPreviewPageIcon { border-color:red !important; }"
        + ".PreviewPageShown #PreviewPageContainer { display:block; }"
        + ".PreviewPageShown .TopLinksPreviewPageIcon { border-color:green !important; }"

        + "#PreviewUserContainer { display:none; }"
        + ".TopLinksPreviewUserIcon { border-color:red !important; }"
        + ".PreviewUserShown #PreviewUserContainer { display:block; }"
        + ".PreviewUserShown .TopLinksPreviewUserIcon { border-color:green !important; }"

        + "#LogListsContainer { display:none; }"
        + ".TopLinksSpecialLogsIcon { border-color:red !important; }"
        + ".SpecialLogsShown #LogListsContainer { display:block; }"
        + ".SpecialLogsShown .TopLinksSpecialLogsIcon { border-color:green !important; }"

        + "#OptionsContainer { display:none; }"
        + ".TopLinksOptionsIcon { border-color:red !important; }"
        + ".OptionsShown #OptionsContainer { display:block; }"
        + ".OptionsShown .TopLinksOptionsIcon { border-color:green !important; }"

        + "#ProgressBarContainer { height:2em;width:100%;background-color:red;border:1px solid black;border-radius:1em;overflow:hidden; }"
        + "#ProgressBar { height:2em;width:0%;background-color:green;border-right:1px sloid black; }"
        + "#ProgressBarLabel { text-align: center;font-size:300%;line-height: 200%;font-weight: bold; }"

        + "#TestedVersion { margin-left:1.5em;font-size:60%; }"







      LiveRC.params.ActualStyleTag = mw.loader.addStyleTag(NewStyles);
    }
  }
}

if( LiveRC.functions.getLaunchCondition()){
    mw.loader.using(['mediawiki.util', 'mediawiki.api'], function(){ 
      $(LiveRC.functions.launch); 
    });
}


} // End script