// License Aggreement prompt______________________

  const popupContainer = document.createElement('div');
  popupContainer.style.position = 'fixed';
  popupContainer.style.top = '0';
  popupContainer.style.left = '0';
  popupContainer.style.width = '100vw';
  popupContainer.style.height = '100vh';
  popupContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
  popupContainer.style.display = 'flex';
  popupContainer.style.justifyContent = 'center';
  popupContainer.style.alignItems = 'center';
  popupContainer.style.zIndex = '9999';
  
  const popupContent = document.createElement('div');
  popupContent.style.backgroundColor = '#fff';
  popupContent.style.borderRadius = '5px';
  popupContent.style.padding = '2rem';
  popupContent.style.width = '80%';
  popupContent.style.maxWidth = '600px';
  popupContent.style.textAlign = 'center';
  
  // BCME logo
  const logo = document.createElement('img');
  logo.src = 'https://media.discordapp.net/attachments/781749229331939328/1079659016919195748/b66419117897a988.png?width=1190&height=1189';
  logo.style.width = '100px';
  logo.style.height = '100px';
  popupContent.appendChild(logo);
  
  const welcomeMessage = document.createElement('h2');
  welcomeMessage.innerText = 'Welcome to BCME, The First Right Click BC Extension';
  popupContent.appendChild(welcomeMessage);
  
  const description = document.createElement('p');
  description.innerText = 'Accept our License Agreement and Privacy Policy below to get started';
  popupContent.appendChild(description);
  
  const buttonsContainer = document.createElement('div');
  buttonsContainer.style.display = 'flex';
  buttonsContainer.style.justifyContent = 'space-between';
  
  const learnMoreButton = document.createElement('a');
  learnMoreButton.href = 'https://bcm.site.live/bcml/';
  learnMoreButton.target = '_blank';
  learnMoreButton.innerText = 'Learn More';
  learnMoreButton.style.backgroundColor = '#007bff';
  learnMoreButton.style.color = '#fff';
  learnMoreButton.style.padding = '0.5rem 1rem';
  learnMoreButton.style.borderRadius = '3px';
  learnMoreButton.style.textDecoration = 'none';
  buttonsContainer.appendChild(learnMoreButton);
  
  const checkboxContainer = document.createElement('label');
  checkboxContainer.style.display = 'flex';
  checkboxContainer.style.alignItems = 'center';
  checkboxContainer.style.padding = '0.5rem 1rem';
  checkboxContainer.style.borderRadius = '50px';
  checkboxContainer.style.backgroundColor = '#fff';
  checkboxContainer.style.boxShadow = '0px 0px 5px #bbb';
  checkboxContainer.style.cursor = 'pointer';
  
  const checkboxInput = document.createElement('input');
  checkboxInput.type = 'checkbox';
  checkboxInput.checked = false; 
  checkboxInput.style.marginRight = '0.5rem';
  checkboxInput.onchange = () => {
    localStorage.setItem('optAnalytics', checkboxInput.checked);
  };
  checkboxContainer.appendChild(checkboxInput);
  
  const checkboxText = document.createTextNode('Limited Analytics (Down)');
  
  const infoIcon = document.createElement('span');
  infoIcon.innerHTML = 'ⓘ';
  infoIcon.style.fontSize = '1rem';
  infoIcon.style.cursor = 'pointer';
  infoIcon.style.marginLeft = '5px'; 
  infoIcon.title = 'Service down';
  
  checkboxContainer.appendChild(checkboxText);
  checkboxContainer.appendChild(infoIcon);
  
  buttonsContainer.appendChild(checkboxContainer);
  
  const acceptButton = document.createElement('button');
  acceptButton.innerText = 'Accept & Continue';
  acceptButton.style.backgroundColor = '#28a745';
  acceptButton.style.color = '#fff';
  acceptButton.style.border = 'none';
  acceptButton.style.padding = '0.5rem 1rem';
  acceptButton.style.borderRadius = '3px';
  acceptButton.style.cursor = 'pointer';
  acceptButton.onclick = () => {
    localStorage.setItem('bcme-accepted', 'true');
    document.body.removeChild(popupContainer);
  };
  buttonsContainer.appendChild(acceptButton);
  
  popupContent.appendChild(buttonsContainer);
  
  const iconsContainer = document.createElement('div');
  iconsContainer.style.position = 'absolute';
  iconsContainer.style.top = '1rem';
  iconsContainer.style.right = '1rem';
  iconsContainer.style.display = 'flex';
  iconsContainer.style.gap = '1rem';
  
  // Discord icon
  const discordIcon = document.createElement('a');
  discordIcon.href = 'https://discord.com/invite/v3JBjyS4mx';
  discordIcon.target = '_blank';
  discordIcon.style.display = 'flex';
  discordIcon.style.justifyContent = 'center';
  discordIcon.style.alignItems = 'center';
  discordIcon.style.width = '40px';
  discordIcon.style.height = '40px';
  discordIcon.style.backgroundColor = '#ccc';
  discordIcon.style.borderRadius = '50%';
  discordIcon.style.backgroundImage = 'url(https://media.discordapp.net/attachments/781749229331939328/1102303883340030042/discord-logo.png?width=922&height=930)';
  discordIcon.style.backgroundRepeat = 'no-repeat';
  discordIcon.style.backgroundSize = 'contain';
  iconsContainer.appendChild(discordIcon);
  
  // Website icon
  const websiteIcon = document.createElement('a');
  websiteIcon.href = 'https://bcm.site.live/bcme/';
  websiteIcon.target = '_blank';
  websiteIcon.style.display = 'flex';
  websiteIcon.style.justifyContent = 'center';
  websiteIcon.style.alignItems = 'center';
  websiteIcon.style.width = '40px';
  websiteIcon.style.height = '40px';
  websiteIcon.style.backgroundColor = '#ccc';
  websiteIcon.style.borderRadius = '50%';
  websiteIcon.style.backgroundImage = 'url(https://media.discordapp.net/attachments/781749229331939328/1102303883658809344/1024px-Globe_icon.svg.png?width=1114&height=1114)';
  websiteIcon.style.backgroundRepeat = 'no-repeat';
  websiteIcon.style.backgroundSize = 'contain';
  iconsContainer.appendChild(websiteIcon);
  
  popupContent.appendChild(iconsContainer);
  
  popupContainer.appendChild(popupContent);
  
  if (localStorage.getItem('bcme-accepted') !== 'true') {
    document.body.appendChild(popupContainer);
  }
  
  if (localStorage.getItem('optAnalytics') === 'true') {
    checkboxInput.checked = true;
  }
  
  //Periodical Debug______________________
  
  //WIP
  async function Fdebug() {}
  
  //End Of Debug______________________
  
  
  //Start Of Loading Screen___________________________________________________________
  const htmlFileUrl = 'https://raw.githubusercontent.com/BCMS7/BCM-/main/loading4';
  fetch(htmlFileUrl)
    .then(response => response.text())
    .then(html => {
      const iframe = document.createElement('iframe');
      iframe.style.position = 'fixed';
      iframe.style.top = '0';
      iframe.style.left = '0';
      iframe.style.width = '138%';
      iframe.style.height = '125%';
      iframe.style.marginLeft = '-19%'; 
      iframe.style.marginTop = '-2%'; 
      iframe.onload = function() {
        const iframeDocument = this.contentWindow.document;
        iframeDocument.open();
        iframeDocument.write(html);
        iframeDocument.close();
      };
      document.body.appendChild(iframe);
  setTimeout(() => {
    document.body.removeChild(iframe);
  }, 7000);
    })
    .catch(error => {
      console.error('Error importing HTML:', error);
    });
  
  
  //End Of Loading Screen ____________________________________________
  
  fetch('https://raw.githubusercontent.com/BCMS7/BCME-External/main/servermaintainance')
    .then(response => response.text())
    .then(data => {
      const regex = /\d+/;
      const match = data.match(regex);
      if (match && parseInt(match[0]) >= 1) {
        function showToastMaint() {
          var toastContainer = document.createElement("div");
          toastContainer.style.position = "fixed";
          toastContainer.style.bottom = "5px";
          toastContainer.style.right = "5px";
          toastContainer.style.backgroundColor = "white";
          toastContainer.style.color = "#141414";
          toastContainer.style.padding = "5px";
          toastContainer.style.border = "2px solid #f22c2c";
          toastContainer.style.borderRadius = "5px";
          toastContainer.style.boxShadow = "2px 2px 10px rgba(0, 0, 0, 0.5)";
          toastContainer.style.display = "none";
          toastContainer.style.zIndex = "999";
          toastContainer.style.transition = "opacity 0.5s ease-in-out";
          toastContainer.style.opacity = "0";
          toastContainer.style.display = "flex";
          toastContainer.style.alignItems = "center";
          var statusBar = document.createElement("div");
      statusBar.style.width = "100%";
      statusBar.style.height = "3px";
      statusBar.style.backgroundColor = "black";
      statusBar.style.position = "absolute";
      statusBar.style.bottom = "0";
      statusBar.style.left = "0";
      statusBar.style.transition = "width 5s ease-in-out";
      statusBar.style.width = "0%";
      toastContainer.appendChild(statusBar);
      setTimeout(function() {
        statusBar.style.width = "100%";
      }, 0);
          
  var closeButton = document.createElement("button");
  closeButton.style.border = "none";
  closeButton.style.background = "none";
  closeButton.style.top = "5px";
  closeButton.style.right = "5px";
  closeButton.style.fontWeight = "bold";
  closeButton.style.fontSize = "16px";
  closeButton.style.marginLeft = "-2px";
  closeButton.style.marginRight = "0px";
  closeButton.innerHTML = "X";
  toastContainer.appendChild(closeButton);
  
  closeButton.addEventListener("click", function() {
    toastContainer.style.opacity = "0";
    setTimeout(function() {
      toastContainer.style.display = "none";
    }, 500);
  });
  
      // BCM Logo Icon
      var icon = document.createElement("img");
      icon.src = "https://media.discordapp.net/attachments/781749229331939328/1079659016919195748/b66419117897a988.png?width=1190&height=1189";
      icon.style.width = "23px";
      icon.style.height = "23px";
      icon.style.borderRadius = "50%";
      icon.style.marginRight = "-30px";
      icon.style.marginBottom = "-5px";
      toastContainer.appendChild(icon);
      
      // Maintenance Text
      var text = document.createElement("span");
      text.style.fontWeight = "bold";
      text.style.marginLeft = "35px";
      text.innerHTML = "BCME servers are under maintainance, try again later";
      toastContainer.appendChild(text);
  
        
       document.body.appendChild(toastContainer);
       setTimeout(function() {
          toastContainer.style.display = "block";
          toastContainer.style.opacity = "1";
         }, 0);
       setTimeout(function() {
           toastContainer.style.opacity = "0";
         }, 5000000);
        
       setTimeout(function() {
           toastContainer.style.display = "none";
          }, 5500000);
        } 
      showToastMaint();     
       throw new Error('Execution stopped.'); 
      } else {
  
  
  //Start Of Context Menu________________________________
  
  //Desktop Menu_______________________
  var visb = true;
  var contextMenuOpen = false;
  function createButton(text, onClick) {
       contextMenuOpen = true;
      var button = document.createElement("div");
      button.innerHTML = text;
      button.onclick = onClick;
      button.style.width = "100%";
      button.style.textAlign = "left";
      button.style.padding = "5px";
      button.style.cursor = "pointer";
      return button;
  }
  
  function createSeparator() {
      var separator = document.createElement("hr");
      separator.style.margin = "5px 0";
      return separator;
  }
  
  // Function to display custom context menu_____
  let contextMenuTimer = null;
  document.addEventListener("contextmenu", function(event) {
    if (contextMenuOpen) {
      event.preventDefault();
      return; // Prevent dupe menus
    }
    if (window.getSelection().toString() !== '') {
      // Show regular context menu when text is highlighted
      return;
    }
    event.preventDefault();
    var contextMenu = document.createElement("div");
    contextMenu.style.position = "fixed";
    contextMenu.style.background = "linear-gradient(to bottom, white, white)";
    contextMenu.style.boxShadow = "0 0 3px #999";
    contextMenu.style.borderRadius = "8px";
    contextMenu.style.zIndex = "9999";
    contextMenu.style.border = "2px solid black";
    contextMenuOpen = true;
    if ('ontouchstart' in window) {
      // Handle long press on mobile devices
      contextMenuTimer = setTimeout(function() {
        contextMenu.style.top = event.touches[0].clientY + "px";
        contextMenu.style.left = event.touches[0].clientX + "px";
        document.body.appendChild(contextMenu);
        contextMenuOpen = true;
      }, 500);
    } else {
      // Handle right click on desktop devices
      contextMenu.style.top = event.clientY + "px";
      contextMenu.style.left = event.clientX + "px";
      document.body.appendChild(contextMenu);
      contextMenuOpen = true;
    }
    document.addEventListener("click", function() {
      contextMenu.style.display = "none";
      contextMenuOpen = false;
      clearTimeout(contextMenuTimer);
    });
      
  
  
      // Header with BCM logo
      var header = document.createElement("div");
      header.style.display = "flex";
      header.style.alignItems = "center";
      header.style.padding = "5px";
  
      var BCMElogo = document.createElement("img");
      BCMElogo.src = "https://media.discordapp.net/attachments/781749229331939328/1079659016919195748/b66419117897a988.png?width=1190&height=1189";
      BCMElogo.style.width = "30px";
      BCMElogo.style.height = "30px";
      BCMElogo.style.borderRadius = "20%";
      BCMElogo.style.marginRight = "10px";
  
      var headerText = document.createElement("div");
      headerText.innerHTML = "Essentials";
  
      header.appendChild(BCMElogo);
      header.appendChild(headerText);
  
   // Custom main buttons
   var button1 = createButton("Restore Character", function() {
      javascript:Player.Appearance = ChatSearchSafewordAppearance.slice(0);  CharacterRefresh(Player);  ChatRoomCharacterUpdate(Player);
      showToastscpg();
      
  });
  var button2 = createButton("Force Room Swap", function() {
      javascript:ChatSelectStartSearch('X'),ChatRoomSetLastChatRoom(''),document['getElementById']('InputChat')['style']['display']='none',document['getElementById']('TextAreaChatLog')['style']['display']='none',ChatSelectStartSearch('X'),ChatRoomSetLastChatRoom('');
      showToastscpg();
  });
  var button3 = createButton("Free Target", function() {
      javascript:CharacterReleaseTotal(CurrentCharacter),ChatRoomCharacterUpdate(CurrentCharacter);
      showToastscpg();
  });
  var button4 = createButton("Remove Restraint", function() {
      javascript:InventoryUnlock(CurrentCharacter, CurrentCharacter.FocusGroup.Name);
      InventoryRemove(CurrentCharacter, CurrentCharacter.FocusGroup.Name);
      ChatRoomCharacterItemUpdate(CurrentCharacter, CurrentCharacter.FocusGroup.Name);
      showToastscpg();
  });
  var button5 = createButton("Target Struggle Difficulty", function() {
      javascript:do{var difc=prompt('Difficulty\x201-96');}while(!(difc>=0x1&&difc<=0x60));
      InventorySetDifficulty(CurrentCharacter, "ItemHead", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemMouth", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemMouth2", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemMouth3", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemArms", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemHands", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemLegs", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemEyes", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemFeet", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemDevices", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemAddon", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemNeck", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemNeckRestraints", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemNeckAccessories", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemBoots", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemHood", difc);
      InventorySetDifficulty(CurrentCharacter, "ItemNose", difc);
      ChatRoomCharacterUpdate(CurrentCharacter);
      showToastscpg();
  });
  var button6 = createButton("Open Target Wardrobe", function() {
      javascript:DialogChangeClothes();
      showToastscpg();
  });
  var button7 = createButton("Complete Struggle Minigame", function() {
      contextMenuOpen = false;
      javascript:StruggleProgress =1000;
      contextMenu.style.display = "none";
      setTimeout(function() {
          ChatRoomClickCharacter(Player);
          DialogLeave();
      }, 500);
      showToastscpg();
  });
  
  var button8 = createButton("Invisible", function() {
      javascript:InventoryGet(Player, "Emoticon").Property.OverrideHeight = {
        Height: "-"
        };
        CurrentScreen === "ChatRoom" ?
        ChatRoomCharacterUpdate(Player) :
        CharacterRefresh(Player);
        ChatRoomCharacterUpdate(Player); 
        visb = false;
        showToastscpg();
        updateContextMenu(); 
  
      
  });
  
  var button9 = createButton("Visible", function() {
    javascript:CharacterSetActivePose(Player, null);
    delete InventoryGet(Player, 'Emoticon').Property.OverrideHeight;
    CurrentScreen === 'ChatRoom' ?
    ChatRoomCharacterUpdate(Player) :
    CharacterRefresh(Player);
        visb = true;
      showToastscpg();
      updateContextMenu(); 
    
  });
  
  var button10 = createButton("Custom Script", function() {
    javascript:var scrp = prompt("Paste your script here:");
    if (scrp) {
      eval(scrp);
      showToastscpg();
    }
  });
  // Transition styling for the buttons
  button1.style.transition = "background-color 0.2s ease-in-out";
  button2.style.transition = "background-color 0.2s ease-in-out";
  button3.style.transition = "background-color 0.2s ease-in-out";
  button4.style.transition = "background-color 0.2s ease-in-out";
  button5.style.transition = "background-color 0.2s ease-in-out";
  button6.style.transition = "background-color 0.2s ease-in-out";
  button7.style.transition = "background-color 0.2s ease-in-out";
  button8.style.transition = "background-color 0.2s ease-in-out";
  button9.style.transition = "background-color 0.2s ease-in-out";
  button10.style.transition = "background-color 0.2s ease-in-out";
  
  
  
  //Hover events for the buttons
  button1.addEventListener("mouseover", function() {
      this.style.backgroundColor = "#dddddd";
      this.style.width = "190px";
      });
  button1.addEventListener("mouseout", function() {
      this.style.backgroundColor = "";
      });
  
  button2.addEventListener("mouseover", function() {
  this.style.backgroundColor = "#dddddd";
  this.style.width = "190px";
  });
  button2.addEventListener("mouseout", function() {
  this.style.backgroundColor = "";
  });
  
  button3.addEventListener("mouseover", function() {
  this.style.backgroundColor = "#dddddd";
  this.style.width = "190px";
  });
  button3.addEventListener("mouseout", function() {
  this.style.backgroundColor = "";
  });
  
  button4.addEventListener("mouseover", function() {
  this.style.backgroundColor = "#dddddd";
  this.style.width = "190px";
  });
  button4.addEventListener("mouseout", function() {
  this.style.backgroundColor = "";
  });
  
  button5.addEventListener("mouseover", function() {
  this.style.backgroundColor = "#dddddd";
  this.style.width = "190px";
  });
  button5.addEventListener("mouseout", function() {
  this.style.backgroundColor = "";
  });
  
  button6.addEventListener("mouseover", function() {
  this.style.backgroundColor = "#dddddd";
  this.style.width = "190px";
  });
  button6.addEventListener("mouseout", function() {
  this.style.backgroundColor = "";
  });
  
  button7.addEventListener("mouseover", function() {
  this.style.backgroundColor = "#dddddd";
  this.style.width = "190.5px";
  });
  button7.addEventListener("mouseout", function() {
  this.style.backgroundColor = "";
  });
  
  button8.addEventListener("mouseover", function() {
  this.style.backgroundColor = "#dddddd";
  this.style.width = "190px";
  });
  button8.addEventListener("mouseout", function() {
  this.style.backgroundColor = "";
  });
  
  button9.addEventListener("mouseover", function() {
  this.style.backgroundColor = "#dddddd";
  this.style.width = "190px";
  });
  button9.addEventListener("mouseout", function() {
  this.style.backgroundColor = "";
  });
  
  button10.addEventListener("mouseover", function() {
  this.style.backgroundColor = "#dddddd";
  this.style.width = "190px";
  });
  button10.addEventListener("mouseout", function() {
  this.style.backgroundColor = "";
  });
  
  //Dropdown Menu__________________________________________
  
  function forceclosemenu() {
    contextMenu.style.display = "none";
    if (Player.LastChatRoom !== '') {
      ChatRoomClickCharacter(Player);
    }
    DialogLeave();
    contextMenuOpen = false;
  }
  
   // Dropdown menu
  var select = document.createElement("select");
  select.style.borderRadius = "2px";
  select.style.padding = "4px";
  select.style.width = "200px";
  select.style.marginTop = "-20px";
  select.style.marginRight = "2px";
  select.style.marginBottom = "3px";
  select.style.marginLeft = "2px";
  var option1 = document.createElement("option");
  option1.value = "opt1";
  option1.text = "Personalisation Menu";
  option1.selected = true;
  option1.disabled = true;
  var option2 = document.createElement("option");
  option2.value = "opt2";
  option2.text = "Edit Cash";
  var option3 = document.createElement("option");
  option3.value = "opt3";
  option3.text = "Max Skills";
  var option4 = document.createElement("option");
  option4.value = "opt4";
  option4.text = "Max Reputation";
  var option5 = document.createElement("option");
  option5.value = "opt5";
  option5.text = "Purchase Everything";
  var option6 = document.createElement("option");
  option6.value = "opt6";
  option6.text = "Release Owner Collar";
  var option7 = document.createElement("option");
  option7.value = "opt7";
  option7.text = "+1 LARP Level";
  var option8 = document.createElement("option");
  option8.value = "opt8";
  option8.text = "Become Escaped Patient";
  var option9 = document.createElement("option");
  option9.value = "opt9";
  option9.text = "Become Club Slave";
  var option10 = document.createElement("option");
  option10.value = "opt10";
  option10.text = "Release Club Title";
  var option11 = document.createElement("option");
  option11.value = "opt11";
  option11.text = "Set GGTS Level";
  var option12 = document.createElement("option");
  option12.value = "opt12";
  option12.text = "Set Dom/Sub Level";
  var option13 = document.createElement("option");
  option13.value = "opt13";
  option13.text = "Set Nickname";
  var option14 = document.createElement("option");
  option14.value = "opt14";
  option14.text = "Force Orgasm";
  var option15 = document.createElement("option");
  option15.value = "opt15";
  option15.text = "BCM Discord";
  var option16 = document.createElement("option");
  option16.value = "opt16";
  option16.text = "Force Lobby";
  var option17 = document.createElement("option");
  option17.value = "opt17";
  option17.text = "LARP Options";
  var option18 = document.createElement("option");
  option18.value = "opt18";
  option18.text = "Emote Menu (` + E)";
  var option19 = document.createElement("option");
  option19.value = "opt19";
  option19.text = "Persistant Settings (` + S)";
  var option20 = document.createElement("option");
  option20.value = "opt20";
  option20.text = "Extension Hub";
  select.appendChild(option1);
  select.appendChild(option20);
  select.appendChild(option2);
  select.appendChild(option3);
  select.appendChild(option4);
  select.appendChild(option12);
  select.appendChild(option5);
  select.appendChild(option6);
  select.appendChild(option7);
  select.appendChild(option8);
  select.appendChild(option9);
  select.appendChild(option10);
  select.appendChild(option11);
  select.appendChild(option13);
  select.appendChild(option14);
  select.appendChild(option16);
  select.appendChild(option17);
  select.appendChild(option18);
  select.appendChild(option19);
  select.appendChild(option15);
  
  
  
  // Button to show the dropdown menu
  var dropdownButton = createButton("Personalisation", function() {
    select.style.display = "block";
  });
  dropdownButton.style.opacity = "0";
  dropdownButton.style.pointerEvents = "none";
  dropdownButton.style.position = "absolute";
  dropdownButton.style.top = "-9999px";
  dropdownButton.style.left = "-9999px";
  select.addEventListener("click", function(event) {
    event.stopPropagation(); 
  });
  
  select.addEventListener("change", function() {
    var selectedOption = select.options[select.selectedIndex].value;
    if (selectedOption === "opt1") {
      javascript:Player.Money = 9999999
      showToastscpg();
      event.stopPropagation();
      event.stopPropagation();
      forceclosemenu();
    } else if (selectedOption === "opt2") {
      javascript:Player.Money = prompt("Enter Cash Amount");
      showToastscpg();
      forceclosemenu();
    } else if (selectedOption === "opt3") {
      javascript:SkillChange("Infiltration", 10);
      SkillChange("SelfBondage", 10);
      SkillChange("Willpower", 10);
      SkillChange("Evasion", 10);
      SkillChange("Bondage", 10);
      SkillChange("Dressage", 10);
      SkillChange("LockPicking", 10);
      showToastscpg();
      forceclosemenu();
    } else if (selectedOption === "opt4") {
      javascript:ReputationChange("Gaming", 100);
      ReputationChange("Gambling", 100);
      ReputationChange("LARP", 100);
      ReputationChange("Maid", 100);
      ReputationChange("ABDL", 100);
      ReputationChange("Nurse", 100);
      showToastscpg();
      forceclosemenu();
    } else if (selectedOption === "opt5") {
      javascript:ServerPlayerSync
      AssetFemale3DCG.forEach(group=>group.Asset.forEach(item=>InventoryAdd(Player, item.Name, group.Group)));
      ServerPlayerInventorySync();
      showToastscpg();
      forceclosemenu();
    } else if (selectedOption === "opt6") {
      javascript:InventoryRemove(Player, "ItemNeck");
      ChatRoomCharacterItemUpdate(Player, "ItemNeck");
      LogAdd("ReleasedCollar", "OwnerRule"); 
      showToastscpg();
      forceclosemenu();
    } else if (selectedOption === "opt7") {
      javascript:alert('Start a LARP session & select class before running');
      GameLARPLevelProgress(100) 
      showToastscpg();
      forceclosemenu();
    } else if (selectedOption === "opt8") {
      javascript:LogAdd("Escaped", "Asylum", CurrentTime + 999999999);
      showToastscpg();
      forceclosemenu();
    } else if (selectedOption === "opt9") {
      javascript:LogAdd("ClubSlave", "Management", CurrentTime + 999999999);
      showToastscpg();
      forceclosemenu();
    } else if (selectedOption === "opt10") {
      javascript:LogAdd("Escaped", "Asylum", CurrentTime);
      LogAdd("ClubSlave", "Management", CurrentTime);
      LogAdd("BlockChange", "Rule", CurrentTime);
      ManagementIsClubSlave = function() {
      return false
      }
      ManagementClubSlaveDialog = function(Player) {}
      ManagementFinishClubSlave()
      showToastscpg();
      forceclosemenu();
    } else if (selectedOption === "opt11") {
      javascript:alert('Start a GGTS session before running, refresh to see changes');
      Player.Game.GGTS.Level = prompt("Enter GGTS Level (1-6)");;
      ServerAccountUpdate.QueueData({
      Game: Player.Game
      });
      showToastscpg();
      forceclosemenu();
      
    }else if (selectedOption === "opt12") {
      javascript:DialogSetReputation("Dominant", prompt("Enter Sub/Dom Rep (-100 to 100)"));
      showToastscpg();
      forceclosemenu();
    }else if (selectedOption === "opt13") {
      javascript:name = prompt("Enter Nickname");;
      Player.Nickname = name;
      ServerAccountUpdate.QueueData({ Nickname: name }, true);   
      showToastscpg();
      forceclosemenu();  
    }else if (selectedOption === "opt14") {
      javascript:ActivitySetArousal(Player, 1);
      ActivityOrgasmPrepare(Player, true);
      ActivityOrgasmGameResistCount = 1;
      showToastscpg();
      forceclosemenu();
    }else if (selectedOption === "opt15") {
      javascript:window.open('https://discord.gg/v3JBjyS4mx', '_blank');
      showToastscpg();
      forceclosemenu();
    }else if (selectedOption === "opt16") {
      javascript:(function() {let input = prompt("Male / Female / Mixed");
      let placeholder;
      
      if (input.toLowerCase() === "male") {
        placeholder = "M";
      } else if (input.toLowerCase() === "mixed") {
        placeholder = "X";
      } else {
        placeholder = "";
      }  
  
      
      ChatRoomStart(placeholder, "", null, null, "Introduction", BackgroundsTagList);
    })();
      showToastscpg();
      forceclosemenu();
    }else if (selectedOption === "opt17") {
      javascript:(function() {let input = prompt("Start a LARP Room as Admin First\nStart / Skip / Mixed / Shuffle / Team / Win (color)").toLowerCase();
  
      if (input === "start") {
        ServerSend("ChatRoomGame", { GameProgress: "Start" });
      } else if (input === "skip") {
        ServerSend("ChatRoomGame", { GameProgress: "Skip" });
      } else if (input === "shuffle") {
        ServerSend("ChatRoomAdmin", { MemberNumber: ChatRoomCharacter[1].MemberNumber, Action: "Shuffle" });
      } else if (input === "team") {
        const Dictionary = new DictionaryBuilder()
        .sourceCharacter(Player)
        .build();
      ServerSend("ChatRoomChat", { Content: "LARPChangeTeamClass", Type: "Action", Dictionary: Dictionary });
    } else if (input.startsWith("win")) {
        let color = input.slice(4).trim();
        color = color.charAt(0).toUpperCase() + color.slice(1);
        GameLARPAddChatLog("EndGame", Player, Player, OnlineGameDictionaryText("Team" + color), 0, 0, "#0000B0");
      }
    })();
  
      showToastscpg();
      forceclosemenu();
    }else if (selectedOption === "opt18") {
    document.body.appendChild(buttonContainer);
    buttonContainer.style.display = "block";
    }else if (selectedOption === "opt19") {
      document.body.appendChild(settingsMenu);
      settingsMenu.style.display = "block";
      showToastscpg();
      forceclosemenu();
    }else if (selectedOption === "opt20") {
      showExtensionHub();
      showToastscpg();
      forceclosemenu();
    }
    
  // Hide dd menu
  select.style.display = "none";
  });
  
  //End of DD menu_____________________________
  
  
  function updateContextMenu() {
    while (contextMenu.firstChild) {
      contextMenu.removeChild(contextMenu.firstChild);
    }
    contextMenu.appendChild(header);
    contextMenu.appendChild(createSeparator());
    contextMenu.appendChild(button1);
    contextMenu.appendChild(button2);
    contextMenu.appendChild(button3);
    contextMenu.appendChild(button4);
    contextMenu.appendChild(button5);
    contextMenu.appendChild(button6);
    contextMenu.appendChild(button7);
    if (visb) {
      contextMenu.appendChild(button8);
    } else {
      contextMenu.appendChild(button9);
    }
    contextMenu.appendChild(button10);
    // Add the dd menu to the context menu
    contextMenu.appendChild(createSeparator());
    contextMenu.appendChild(dropdownButton);
    contextMenu.appendChild(select);
    
  }
  updateContextMenu();
  // Update context  menu when opened
  contextMenu.addEventListener('contextmenu', function() {
    updateContextMenu();
  });
  document.body.appendChild(contextMenu);
  });
  
  // Hide the context menu
  document.addEventListener("click", function() {
      if (contextMenuOpen) {
          var contextMenu = document.querySelector("div[style*='fixed']");
          if (contextMenu) {
              contextMenu.style.display = "none";
              ChatRoomClickCharacter(Player);
              DialogLeave();
          }
          contextMenuOpen = false;
      }
  });
  
  //S Extension Hub___________________
  
  /*
  The extension hub utilizes verbatim loaders from various extensions, each of which is licensed under the GNU 3.0 Public License as of the 3rd day of May, 2023.
  All extensions utilized within this hub belong to their respective authors and are listed below solely for the purposes of proper attribution:
    
    - FBC: https://gitlab.com/Sidiousious/bce/-/blob/main/LICENSE
    - BCX: https://github.com/Jomshir98/bondage-club-extended/blob/master/LICENSE
    - MBS: https://github.com/bananarama92/MBS/blob/main/LICENSE
    - BCT: https://github.com/agicitag/BCTweaks/blob/main/LICENSE
    - BCAR: https://github.com/DrBranestawm/BCAR/blob/main/LICENSE
    - LSCG: Author Confirmed
  
   
   The use of said verbatim loaders in this hub is fully compliant with the terms of the GNU 3.0 Public License § 4. 
   For further details, please refer to the license link included with each extension.
  */
  
  
    let fbcLoaded = false;
    let bcxLoaded = false;
    let mbsLoaded = false;
    let bcarLoaded = false;
    let bctLoaded = false;
    let lscgLoaded = false;
  
    function loadFBC() {
      if (fbcLoaded) {
        return;
      }
      const script = document.createElement("script");
      script.src = `https://sidiousious.gitlab.io/bce/bce.user.js?v=${(
        Date.now() / 10000
      ).toFixed(0)}`;
      document.head.appendChild(script);
      fbcLoaded = true;
    }
    
    function loadBCX() {
      if (bcxLoaded) {
          return;
        }
      setTimeout(() => {
        if (window.BCX_Loaded === undefined) {
          const n = document.createElement("script");
          n.setAttribute("language", "JavaScript");
          n.setAttribute("crossorigin", "anonymous");
          n.setAttribute(
            "src",
            "https://jomshir98.github.io/bondage-club-extended/bcx.js?_=" + Date.now()
          );
          n.onload = () => n.remove();
          document.head.appendChild(n);
        }
      }, 2000);
      bcxLoaded = true;
    }
    
    function loadMBS() {
      if (mbsLoaded) {
          return;
        }
      setTimeout(() => {
        const n = document.createElement("script");
        n.language = "JavaScript";
        n.crossorigin = "anonymous";
        n.src = "https://bananarama92.github.io/MBS/main/mbs.js";
        document.head.appendChild(n);
      }, 2000);
      mbsLoaded = true;
    }
    
    function loadBCAR() {
      if (bcarLoaded) {
          return;
        }
      const script = document.createElement("script");
      script.src = "https://drbranestawm.github.io/BCAR/script/bcarBeta.js";
      document.head.appendChild(script);
      bcarLoaded = true;
    }
    
    function loadBCT() {
      if (bctLoaded) {
          return;
        }
      const script = document.createElement("script");
      script.src = "https://agicitag.github.io/BCTweaks/beta/extension/bct.js";
      document.head.appendChild(script);
      bctLoaded = true;
    }
  
    function loadLSCG() {
      if (lscgLoaded) {
          return;
        }
        (function() {
          'use strict';
          var script = document.createElement("script");
          script.type = "module";
          script.setAttribute("crossorigin", "anonymous");
          script.src = "https://littlesera.github.io/LSCG/bundle.js?" + Date.now().toString();
          document.head.appendChild(script);
          
      })();
      lscgLoaded = true;
  
    }
    
  const options = [
      { name: "FBC", description: "Includes many useful QOL features, useful for most members." },
      { name: "BCX", description: "Offers extra rules and curses, a must have for members seeking immersion." },
      { name: "MBS", description: "Expands the club's default wheel of fortune with custom restraint sets." },
      { name: "BCT", description: "Adds functionality such as split arousal bar and  best friends." },
      { name: "BCAR", description: "Allows you to animate actions for tails, ears and wings." },
      { name: "LSCG", description: "Auto reactions to events, expands RP potential." },
      { name: "EBCHC (Soon)", description: "Waiting on author.\n" },
    ];
    
    function createToggleButton(option) {
      const container = document.createElement("div");
      container.style.display = "flex";
      container.style.alignItems = "center";
      container.style.marginBottom = "10px";
    
      const wrapper = document.createElement("div");
      wrapper.style.display = "flex";
      wrapper.style.alignItems = "center";
      wrapper.style.backgroundColor = "#ccc";
      wrapper.style.borderRadius = "10px";
      wrapper.style.padding = "5px";
      container.appendChild(wrapper);
    
      const box = document.createElement("div");
      box.style.width = "40px";
      box.style.height = "20px";
      box.style.borderRadius = "10px";
      box.style.backgroundColor = "#d82752";
      box.style.marginRight = "10px";
      box.style.cursor = "pointer";
      wrapper.appendChild(box);
    
      const label = document.createElement("div");
      label.textContent = option.name;
      wrapper.appendChild(label);
    
      const description = document.createElement("div");
      description.textContent = option.description;
      description.style.marginLeft = "15px";
      container.appendChild(description);
    
      function toggle() {
        const value = localStorage.getItem(option.name);
        const newValue = value === "true" ? "false" : "true";
        localStorage.setItem(option.name, newValue);
        box.style.backgroundColor = newValue === "true" ? "#5cb85c" : "#d82752";
        if (newValue === "true") {
          {
              if (option.name === "FBC") {
                  loadFBC();
              } else if (option.name === "BCX") {
                  loadBCX();
                }else if (option.name === "MBS") {
                  loadMBS();
                }else if (option.name === "BCAR") {
                  loadBCAR();
                }else if (option.name === "BCT") {
                  loadBCT();
                }else if (option.name === "LSCG") {
                  loadLSCG();
                }
            }
        }
      }
        box.addEventListener("click", toggle);
        const value = localStorage.getItem(option.name);
      if (value === "true") {
        box.style.backgroundColor = "#5cb85c";
        {
          if (option.name === "FBC") {
              loadFBC();
          } else if (option.name === "BCX") {
              loadBCX();
            }else if (option.name === "MBS") {
              loadMBS();
            }else if (option.name === "BCAR") {
              loadBCAR();
            }else if (option.name === "BCT") {
              loadBCT();
            }else if (option.name === "LSCG") {
              loadLSCG();
            }
        }
      }
      return container;
    }
    
    function createExtensionHub() {
      const container = document.createElement("div");
      container.style.position = "fixed";
      container.style.top = "0";
      container.style.left = "0";
      container.style.marginLeft = "10px";
      container.style.marginTop = "10px";
      container.style.width = "600px";
      container.style.backgroundColor = "#fff";
      container.style.borderRadius = "10px";
      container.style.padding = "10px";
      container.style.boxShadow = "0 0 10px rgba(0, 0, 0, 0.5)";
      container.style.border = "0.8px solid #000"; 
      container.style.zIndex = "9999";
    
      const CTN = document.createElement("div");
      CTN.style.display = "flex";
      CTN.style.alignItems = "center";
    
      const logo = document.createElement("img");
      logo.src =
        "https://media.discordapp.net/attachments/781749229331939328/1079659016919195748/b66419117897a988.png?width=1190&height=1189";
      logo.style.width = "50px";
      logo.style.height = "50px";
      logo.style.marginRight = "15px";
      logo.style.marginBottom = "10px";
      CTN.appendChild(logo);
    
      const title = document.createElement("div");
      title.textContent = "Extension Hub";
      title.style.fontSize = "20px";
      title.style.fontWeight = "bold";
      title.style.marginBottom = "15px";
      CTN.appendChild(title);
    
      container.appendChild(CTN);
    
      options.forEach((option) => {
        const toggleButton = createToggleButton(option);
        container.appendChild(toggleButton);
      });
    
      return container;
    }
    
    function showExtensionHub() {
      const settingsMenu = createExtensionHub();
      document.body.appendChild(settingsMenu);
    
      function clickOffMenu(event) {
        if (!settingsMenu.contains(event.target)) {
          document.body.removeChild(settingsMenu);
          document.removeEventListener("click", clickOffMenu);
        }
      }
      document.addEventListener("click", clickOffMenu);
    }
  
    
    document.addEventListener("keydown", listenForShortcut);
    function initializeToggleButtons() {
      options.forEach((option) => {
        const value = localStorage.getItem(option.name);
        if (value === "true") {
          if (option.name === "FBC") {
              loadFBC();
          } else if (option.name === "BCX") {
              loadBCX();
            }else if (option.name === "MBS") {
              loadMBS();
            }else if (option.name === "BCAR") {
              loadBCAR();
            }else if (option.name === "BCT") {
              loadBCT();
            }else if (option.name === "LSCG") {
              loadLSCG();
            }
        }
      });
    }
    function listenForShortcut(event) {
    }
    initializeToggleButtons();
  
  //E Extension Hub___________________
  
  //Start of keyboard shortcuts___________________
  
  let backtickPressed = false;
  let lastKeyPressed = null;
  
  document.addEventListener("keydown", function(event) {
    if (event.key === "`" && !backtickPressed) {
      backtickPressed = true;
    }
    else if (backtickPressed) {
      lastKeyPressed = event.key;
    }
  });
  
  document.addEventListener("keyup", function(event) {
    if (event.key === "`") {
      backtickPressed = false;
      lastKeyPressed = null;
    }
  });
  
  setInterval(function() {
    if (lastKeyPressed === "," || lastKeyPressed === ".") {
      let action = lastKeyPressed === "," ? "MoveLeft" : "MoveRight";
      ServerSend("ChatRoomAdmin", {
        MemberNumber: Player.MemberNumber,
        Action: action,
      });
    }
  }, 50);
  //Start of Persistant Menu _____________________
  
  const settingsMenu = document.createElement("div");
  settingsMenu.id = "settings-menu";
  settingsMenu.style.position = "fixed";
  settingsMenu.style.top = "20px";
  settingsMenu.style.left = "20px";
  settingsMenu.style.backgroundColor = "#fff";
  settingsMenu.style.border = "1px solid #ccc";
  settingsMenu.style.padding = "3px";
  settingsMenu.style.borderRadius = "10px";
  settingsMenu.style.display = "none";
  settingsMenu.style.zIndex = "9999";
  
  //BCM logo   
  const BCMElogo1 = document.createElement("img");
  BCMElogo1.src = "https://media.discordapp.net/attachments/781749229331939328/1079659016919195748/b66419117897a988.png?width=1190&height=1189";
  BCMElogo1.style.float = "left";
  BCMElogo1.style.marginRight = "10px";
  BCMElogo1.style.width = "40px"; 
  BCMElogo1.style.height = "40px"; 
  settingsMenu.appendChild(BCMElogo1);
  
  //Options and style_____________________________
  
  const option1 = document.createElement("label");
  option1.textContent = "Antiblind";
  const checkbox1 = document.createElement("input");
  checkbox1.type = "checkbox";
  checkbox1.id = "option1";
  checkbox1.style.marginRight = "5px";
  checkbox1.style.verticalAlign = "middle";
  option1.appendChild(checkbox1);
  settingsMenu.appendChild(option1);
  
  const option2 = document.createElement("label");
  option2.textContent = "Realistic Talking";
  const checkbox2 = document.createElement("input");
  checkbox2.type = "checkbox";
  checkbox2.id = "option2";
  checkbox2.style.marginRight = "5px";
  checkbox2.style.verticalAlign = "middle";
  option2.appendChild(checkbox2);
  settingsMenu.appendChild(option2);
  
  const option3 = document.createElement("label");
  option3.textContent = "Sound";
  const checkbox3 = document.createElement("input");
  checkbox3.type = "checkbox";
  checkbox3.id = "option3";
  checkbox3.style.marginRight = "5px";
  checkbox3.style.verticalAlign = "middle";
  option3.appendChild(checkbox3);
  settingsMenu.appendChild(option3);
  
  option1.style.display = "flex";
  option1.style.justifyContent = "center";
  option1.style.alignItems = "center";
  option1.style.marginBottom = "10px";
  option1.style.padding = "5px";
  option1.style.borderRadius = "5px";
  option1.style.backgroundColor = "#f2f2f2";
  
  option2.style.display = "flex";
  option2.style.justifyContent = "center";
  option2.style.alignItems = "center";
  option2.style.marginBottom = "10px";
  option2.style.padding = "5px";
  option2.style.borderRadius = "5px";
  option2.style.backgroundColor = "#f2f2f2";
  
  option3.style.display = "flex";
  option3.style.justifyContent = "center";
  option3.style.alignItems = "center";
  option3.style.marginBottom = "10px";
  option3.style.padding = "5px";
  option3.style.borderRadius = "5px";
  option3.style.backgroundColor = "#f2f2f2";
  
  option1.addEventListener("mouseenter", function() {
    option1.style.backgroundColor = "#ddd";
    option1.style.cursor = "pointer";
  });
  
  option1.addEventListener("mouseleave", function() {
    if (checkbox1.checked) {
      option1.style.backgroundColor = "lightgreen";
    } else {
      option1.style.backgroundColor = "#f2f2f2";
    }
  });
  
  option2.addEventListener("mouseenter", function() {
    option2.style.backgroundColor = "#ddd";
    option2.style.cursor = "pointer";
  });
  
  option2.addEventListener("mouseleave", function() {
    if (checkbox2.checked) {
      option2.style.backgroundColor = "lightgreen";
    } else {
      option2.style.backgroundColor = "#f2f2f2";
    }
  });
  
  option3.addEventListener("mouseenter", function() {
    option3.style.backgroundColor = "#ddd";
    option3.style.cursor = "pointer";
  });
  
  option3.addEventListener("mouseleave", function() {
    if (checkbox3.checked) {
      option3.style.backgroundColor = "lightgreen";
    } else {
      option3.style.backgroundColor = "#f2f2f2";
    }
  });
  
  // Checkbox state when the page loads
  checkbox1.checked ? option1.style.backgroundColor = "#d1f7c4" : option1.style.backgroundColor = "#f2f2f2";
  checkbox2.checked ? option2.style.backgroundColor = "#d1f7c4" : option2.style.backgroundColor = "#f2f2f2";
  checkbox3.checked ? option3.style.backgroundColor = "#d1f7c4" : option3.style.backgroundColor = "#f2f2f2";
  
  
  // Changes label background color when the checkbox is checked
  checkbox1.addEventListener("change", function() {
    if (checkbox1.checked) {
      option1.style.backgroundColor = "#d1f7c4";
    } else {
      option1.style.backgroundColor = "#f2f2f2";
    }
  });
  checkbox2.addEventListener("change", function() {
    if (checkbox2.checked) {
      option2.style.backgroundColor = "#d1f7c4";
    } else {
      option2.style.backgroundColor = "#f2f2f2";
    }
  });
  checkbox3.addEventListener("change", function() {
    if (checkbox3.checked) {
      option3.style.backgroundColor = "#d1f7c4";
    } else {
      option3.style.backgroundColor = "#f2f2f2";
    }
  });
  
  //Options Actions_____________________________
  
  function runOption1() {
      if (checkbox1.checked) {
        function GetBlindLevel0() {
          let blindLevel = 0;
          return blindLevel;
        }
        Player.GetBlindLevel = GetBlindLevel0;
        Player.GetBlindLevel();
      }
    }
    
    function runOption2() {
      function RunExpressionAnimationStep() {
        CharacterSetFacialExpression(Player, "Mouth", expressionAnimation[expressionAnimationIndex++]);
        if (expressionAnimationIndex < expressionAnimation.length) {
          setTimeout(RunExpressionAnimationStep, 1000);
        } else {
          expressionAnimation = null;
        }
      }
    
      function RunExpressionAnimation(list) {
        if (expressionAnimation) {
          return;
        }
        expressionAnimation = list;
        expressionAnimationIndex = 0;
        expressionAnimationEx = InventoryGet(Player, "Mouth");
        if (expressionAnimationEx && expressionAnimationEx.Property && expressionAnimationEx.Property.Expression) {
          expressionAnimation[expressionAnimation.length - 1] = expressionAnimationEx.Property.Expression; //set last to current
        }
        RunExpressionAnimationStep();
      }
    
      function NEWtalking() {
        var msg = ElementValue("InputChat").trim();
        if (!msg.startsWith("/") && !msg.startsWith("*") && !msg.startsWith("!")) {
          if (msg.length > 10) {
            RunExpressionAnimation([null, "Grin", "Smirk", null, "Grin", "Smirk", null]);
          } else {
            RunExpressionAnimation([null, "Grin", "Smirk", null]);
          }
        }
        OLDtalking();
      }
    
      if (checkbox2.checked) {
        var expressionAnimation;
        var expressionAnimationIndex = 0;
        var OLDtalking = ChatRoomSendChat;
        ChatRoomSendChat = NEWtalking;
      }
    }
  
    function runOption3() {
      if (checkbox3.checked) {
        function showToastscpg() {
          AudioPlayInstantSound("https://cdn.discordapp.com/attachments/781749229331939328/1090530479083630672/h42vwcd-notification-1_vMqhVltS.mp3", 1);
          // Create the toast container
          var toastContainer = document.createElement("div");
          toastContainer.style.position = "fixed";
          toastContainer.style.bottom = "5px";
          toastContainer.style.right = "5px";
          toastContainer.style.backgroundColor = "white";
          toastContainer.style.color = "#141414";
          toastContainer.style.padding = "5px";
          toastContainer.style.border = "2px solid #4CAF50";
          toastContainer.style.borderRadius = "5px";
          toastContainer.style.boxShadow = "2px 2px 10px rgba(0, 0, 0, 0.5)";
          toastContainer.style.display = "none";
          toastContainer.style.zIndex = "999";
          toastContainer.style.transition = "opacity 0.5s ease-in-out";
          toastContainer.style.opacity = "0";
          toastContainer.style.display = "flex";
          toastContainer.style.alignItems = "center";
          var statusBar = document.createElement("div");
      statusBar.style.width = "100%";
      statusBar.style.height = "3px";
      statusBar.style.backgroundColor = "black";
      statusBar.style.position = "absolute";
      statusBar.style.bottom = "0";
      statusBar.style.left = "0";
      statusBar.style.transition = "width 5s ease-in-out";
      statusBar.style.width = "0%";
      toastContainer.appendChild(statusBar);
      
      // Status bar width while counting down
      setTimeout(function() {
        statusBar.style.width = "100%";
      }, 0);
      var icon = document.createElement("img");
      icon.src = "https://media.discordapp.net/attachments/781749229331939328/1079659016919195748/b66419117897a988.png?width=1190&height=1189";
      icon.style.width = "23px";
      icon.style.height = "23px";
      icon.style.borderRadius = "50%";
      icon.style.marginRight = "-30px";
      icon.style.marginBottom = "-5px";
      toastContainer.appendChild(icon);
      var text = document.createElement("span");
      text.style.fontWeight = "bold";
      text.style.marginLeft = "35px";
      text.innerHTML = "Action Successfully Executed";
      toastContainer.appendChild(text);
      document.body.appendChild(toastContainer);
        
          setTimeout(function() {
            toastContainer.style.display = "block";
            toastContainer.style.opacity = "1";
          }, 0);
        
          setTimeout(function() {
            toastContainer.style.opacity = "0";
          }, 5000);
        
          setTimeout(function() {
            toastContainer.style.display = "none";
          }, 5500);
          Fdebug();
      
        }
  
      }
    }
  
    if (localStorage.getItem("option1") !== null) {
      checkbox1.checked = localStorage.getItem("option1") === "true";
      if (checkbox1.checked) {
        setInterval(runOption1, 1000);
      }
    }
    
    if (localStorage.getItem("option2") !== null) {
      checkbox2.checked = localStorage.getItem("option2") === "true";
      if (checkbox2.checked) {
        setInterval(runOption2, 1000);
      }
    }
  
    if (localStorage.getItem("option3") !== null) {
      checkbox3.checked = localStorage.getItem("option3") === "true";
      if (checkbox3.checked) {
        setInterval(runOption3, 1000);
      }
    }
    
    checkbox1.addEventListener("change", function() {
      localStorage.setItem("option1", checkbox1.checked);
      if (checkbox1.checked) {
        setInterval(runOption1, 1000);
      }
    });
    
    checkbox2.addEventListener("change", function() {
      localStorage.setItem("option2", checkbox2.checked);
      if (checkbox2.checked) {
        setInterval(runOption2, 1000);
      }
    });
  
    checkbox3.addEventListener("change", function() {
      localStorage.setItem("option3", checkbox3.checked);
      if (checkbox3.checked) {
        setInterval(runOption3, 1000);
      }
    });
    
  
  //Options States_____________________________
  
  checkbox1.addEventListener("change", function() {
    localStorage.setItem("option1", checkbox1.checked);
  });
  
  checkbox2.addEventListener("change", function() {
    localStorage.setItem("option2", checkbox2.checked);
  });
  
  checkbox3.addEventListener("change", function() {
    localStorage.setItem("option3", checkbox3.checked);
  });
  
  
  document.body.appendChild(settingsMenu);
  
  let isBacktickPressed = false;
  let isSPressed = false;
  
  document.addEventListener("keydown", function(event) {
    if (event.key === "`") {
      isBacktickPressed = true;
    } else if (event.key === "s") {
      isSPressed = true;
    }
  
    if (isBacktickPressed && isSPressed) {
      settingsMenu.style.display = "block";
    }
  });
  
  // Hide settings menu when user clicks off
  document.addEventListener("click", function(event) {
      const targetElement = event.target;
      const isSettingsMenu = !!targetElement.closest("#settings-menu");
      
      if (!isSettingsMenu) {
        settingsMenu.style.display = "none";
      }
    });
    
    document.addEventListener("keyup", function(event) {
    if (event.key === "`") {
      isBacktickPressed = false;
    } else if (event.key === "s") {
      isSPressed = false;
    }
  });
  
  
  //End of Persistant Menu _____________________
  
  //Start of Emote Menu _____________________
  
  const buttonData = [
    { name: "Pull-Ups", action: () => {
          showToastscpg();
          CharacterSetActivePose(Player, null);
          setTimeout(function() {
              CharacterSetActivePose(Player, "LegsOpen");
              CharacterSetActivePose(Player, "OverTheHead");
              InventoryGet(Player, "Emoticon").Property.OverrideHeight = {
                  Height: 130
              };
              CurrentScreen === "ChatRoom" ?
                  ChatRoomCharacterUpdate(Player) :
                  CharacterRefresh(Player);
          }, 1000);
          setTimeout(function() {
              CharacterSetActivePose(Player, "Yoked");
              CharacterSetActivePose(Player, "LegsClosed");
              InventoryGet(Player, "Emoticon").Property.OverrideHeight = {
                  Height: 250
              };
              CurrentScreen === "ChatRoom" ?
                  ChatRoomCharacterUpdate(Player) :
                  CharacterRefresh(Player);
          }, 2000);
          setTimeout(function() {
  
              CharacterSetActivePose(Player, "LegsOpen");
              CharacterSetActivePose(Player, "OverTheHead")
              InventoryGet(Player, "Emoticon").Property.OverrideHeight = {
                  Height: 130
              };
              CurrentScreen === "ChatRoom" ?
                  ChatRoomCharacterUpdate(Player) :
                  CharacterRefresh(Player);
          }, 3000);
          setTimeout(function() {
              CharacterSetActivePose(Player, "Yoked");
              CharacterSetActivePose(Player, "LegsClosed");
              InventoryGet(Player, "Emoticon").Property.OverrideHeight = {
                  Height: 250
              };
              CurrentScreen === 'ChatRoom' ?
                  ChatRoomCharacterUpdate(Player) :
                  CharacterRefresh(Player);
          }, 4000);    
          setTimeout(function() {
              CharacterSetActivePose(Player, "LegsOpen");
              CharacterSetActivePose(Player, "OverTheHead")
              InventoryGet(Player, "Emoticon").Property.OverrideHeight = {
                  Height: 130
              };
              CurrentScreen === "ChatRoom" ?
                  ChatRoomCharacterUpdate(Player) :
                  CharacterRefresh(Player);
          }, 5000);
          setTimeout(function() {
              CharacterSetActivePose(Player, null);
              delete InventoryGet(Player, 'Emoticon').Property.OverrideHeight;
              CurrentScreen === 'ChatRoom' ?
                  ChatRoomCharacterUpdate(Player) :
                  CharacterRefresh(Player);
          }, 6000);    
  } },
    { name: "Cheer", action: () => {
      showToastscpg();
       CharacterSetActivePose(Player, null);
        setTimeout(function() {
            CharacterSetActivePose(Player, "Yoked");
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 1000);
        setTimeout(function() {
            CharacterSetActivePose(Player, "OverTheHead");
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 2000);
        setTimeout(function() {
            CharacterSetActivePose(Player, "Yoked");
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 3000);
        setTimeout(function() {
            CharacterSetActivePose(Player, "OverTheHead");
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 4000);    
        setTimeout(function() {
            CharacterSetActivePose(Player, "Yoked");
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 5000);
        setTimeout(function() {
            CharacterSetActivePose(Player, "OverTheHead");
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 6000);
        setTimeout(function() {
            CharacterSetActivePose(Player, null);
            CurrentScreen === 'ChatRoom' ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 7000); } },
    { name: "Jumping Jacks", action: () => {
      showToastscpg();
       CharacterSetActivePose(Player, null);
        setTimeout(function() {
            InventoryGet(Player, "Emoticon").Property.OverrideHeight = {
                Height: 150
            };
            CharacterSetActivePose(Player, "LegsOpen");
            CharacterSetActivePose(Player, "OverTheHead");
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 1000);
        setTimeout(function() {
            InventoryGet(Player, "Emoticon").Property.OverrideHeight = undefined;
            CharacterSetActivePose(Player, null);
            CharacterSetActivePose(Player, "LegsClosed");
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 2000);
        setTimeout(function() {
            InventoryGet(Player, "Emoticon").Property.OverrideHeight = {
                Height: 150
            };
            CharacterSetActivePose(Player, "LegsOpen");
            CharacterSetActivePose(Player, "OverTheHead")
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 3000);
        setTimeout(function() {
            CharacterSetActivePose(Player, null);
            delete InventoryGet(Player, 'Emoticon').Property.OverrideHeight;
            CurrentScreen === 'ChatRoom' ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 4000);     } },
    { name: "Burpees", action: () => {
      showToastscpg();
      CharacterSetActivePose(Player, null);
        setTimeout(function() {
            CharacterSetActivePose(Player, "Hogtied");
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 1000);
        setTimeout(function() {
            CharacterSetActivePose(Player, null);
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 2000);
        setTimeout(function() {
            CharacterSetActivePose(Player, "Yoked");
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 3000);
        setTimeout(function() {
            CharacterSetActivePose(Player, null);
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 4000);    
        setTimeout(function() {
            CharacterSetActivePose(Player, "Hogtied");
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 5000);
        setTimeout(function() {
            CharacterSetActivePose(Player, null);
            CurrentScreen === "ChatRoom" ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 6000);
        setTimeout(function() {
            CharacterSetActivePose(Player, "Yoked");
            CurrentScreen === 'ChatRoom' ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 7000);
        setTimeout(function() {
            CharacterSetActivePose(Player, null);
            CurrentScreen === 'ChatRoom' ?
                ChatRoomCharacterUpdate(Player) :
                CharacterRefresh(Player);
        }, 8000); } },
    { name: "Sleep", action: () => {
      showToastscpg();
      CharacterSetActivePose(Player, "Hogtied");
    CharacterSetFacialExpression(Player, "Eyes", "Closed");
    CharacterSetFacialExpression(Player, "Eyes2", "Closed");
    CharacterSetFacialExpression(Player, "Emoticon", "Sleep");
    ChatRoomCharacterUpdate(Player);  } }
  ];
  
  const buttonContainer = document.createElement("div");
  buttonContainer.style.position = "fixed";
  buttonContainer.style.width = "300px";
  buttonContainer.style.height = "300px";
  buttonContainer.style.left = "50%";
  buttonContainer.style.top = "50%";
  buttonContainer.style.transform = "translate(-50%, -50%)";
  buttonContainer.style.display = "none";
  const buttonCircle = document.createElement("div");
  buttonCircle.style.position = "absolute";
  buttonCircle.style.width = "200px";
  buttonCircle.style.height = "200px";
  buttonCircle.style.borderRadius = "50%";
  buttonCircle.style.backgroundColor = "white";
  buttonCircle.style.opacity = "1";
  buttonCircle.style.left = "50%";
  buttonCircle.style.top = "50%";
  buttonCircle.style.transform = "translate(-50%, -50%)";
  buttonCircle.style.transition = "opacity 0.2s ease-in-out";
  buttonCircle.style.border = "2px solid black";
  
  buttonContainer.appendChild(buttonCircle);
  const logo = document.createElement("img");
  logo.src = "https://media.discordapp.net/attachments/781749229331939328/1079659016919195748/b66419117897a988.png?width=1190&height=1189";
  logo.style.position = "absolute";
  logo.style.width = "80px";
  logo.style.height = "80px";
  logo.style.borderRadius = "50%";
  logo.style.left = "50%";
  logo.style.top = "50%";
  logo.style.transform = "translate(-50%, -50%)";
  buttonCircle.appendChild(logo);
  const buttons = [];
  for (let i = 0; i < buttonData.length; i++) {
    const button = document.createElement("button");
    button.innerText = buttonData[i].name;
    button.style.position = "absolute";
    button.style.width = "80px";
    button.style.height = "80px";
    button.style.borderRadius = "50%";
    button.style.backgroundColor = "black";
    button.style.color = "white";
    button.style.boxShadow = "0 2px 5px rgba(0, 0, 0, 0.3)";
    button.style.left = "50%";
    button.style.top = "50%";
    button.style.transform = `translate(-50%, -50%) rotate(${i * (360 / buttonData.length)}deg) translate(0, -100px) rotate(${-i * (360 / buttonData.length)}deg)`;
    button.style.transition = "opacity 0.2s ease-in-out, transform 0.2s ease-in-out";
    button.addEventListener("click", buttonData[i].action);
    buttonContainer.appendChild(button);
    buttons.push(button);
  
    button.addEventListener("mouseenter", () => {
      button.style.transform = `translate(-50%, -50%) rotate(${i * (360 / buttonData.length)}deg) translate(0, -99px) rotate(${-i * (360 / buttonData.length)}deg) scale(1.05)`;
    });
  
    button.addEventListener("mouseleave", () => {
      button.style.transform = `translate(-50%, -50%) rotate(${i * (360 / buttonData.length)}deg) translate(0, -100px) rotate(${-i * (360 / buttonData.length)}deg) scale(1)`;
    });
  }
  
  
  
  let isGraveKeyDown = false;
  document.addEventListener("keydown", (event) => {
  if (event.key === "`") {
    isGraveKeyDown = true;
  } else if (isGraveKeyDown && event.key === "e") {
    document.body.appendChild(buttonContainer);
    buttonContainer.style.display = "block";
    isGraveKeyDown = false;
  }
  });
  document.addEventListener("keyup", (event) => {
  if (event.key === "`") {
    isGraveKeyDown = false;
  }
  });
  
  document.addEventListener("click", (event) => {
    if (!buttonContainer.contains(event.target)) {
      if (buttonContainer.parentNode === document.body) {
        document.body.removeChild(buttonContainer);
      }
      buttonContainer.style.display = "none";
    }
  });
  
  //End Of Emote Menu __________________
  
  //END OF CONTEXT MENU --------------------------------------
  
  //BCME LOGO On Character
  //Adapted and compatible with MBCHC, MBCHC users shows a red logo instead, read more: https://code.fleshless.org/mute/MBCHC/src/branch/master/LICENSE
  fetch('https://raw.githubusercontent.com/BCMS7/BCME-External/main/charlogo.js')
  .then(response => response.text())
  .then(text => {
  const script = document.createElement('script');
  script.innerHTML = text;
  document.head.appendChild(script);
  })
  
  
  function showToastscpg() {
    if (localStorage.getItem("option3") !== null) {
      checkbox3.checked = localStorage.getItem("option3") === "true";
      if (checkbox3.checked) {
        AudioPlayInstantSound("https://cdn.discordapp.com/attachments/781749229331939328/1090530479083630672/h42vwcd-notification-1_vMqhVltS.mp3", 1);
      }
    }
      var toastContainer = document.createElement("div");
      toastContainer.style.position = "fixed";
      toastContainer.style.bottom = "5px";
      toastContainer.style.right = "5px";
      toastContainer.style.backgroundColor = "white";
      toastContainer.style.color = "#141414";
      toastContainer.style.padding = "5px";
      toastContainer.style.border = "2px solid #4CAF50";
      toastContainer.style.borderRadius = "5px";
      toastContainer.style.boxShadow = "2px 2px 10px rgba(0, 0, 0, 0.5)";
      toastContainer.style.display = "none";
      toastContainer.style.zIndex = "999";
      toastContainer.style.transition = "opacity 0.5s ease-in-out";
      toastContainer.style.opacity = "0";
      toastContainer.style.display = "flex";
      toastContainer.style.alignItems = "center";
      var statusBar = document.createElement("div");
  statusBar.style.width = "100%";
  statusBar.style.height = "3px";
  statusBar.style.backgroundColor = "black";
  statusBar.style.position = "absolute";
  statusBar.style.bottom = "0";
  statusBar.style.left = "0";
  statusBar.style.transition = "width 5s ease-in-out";
  statusBar.style.width = "0%";
  toastContainer.appendChild(statusBar);
  setTimeout(function() {
    statusBar.style.width = "100%";
  }, 0);
      
  var icon = document.createElement("img");
  icon.src = "https://media.discordapp.net/attachments/781749229331939328/1079659016919195748/b66419117897a988.png?width=1190&height=1189";
  icon.style.width = "23px";
  icon.style.height = "23px";
  icon.style.borderRadius = "50%";
  icon.style.marginRight = "-30px";
  icon.style.marginBottom = "-5px";
  toastContainer.appendChild(icon);
  
  var text = document.createElement("span");
  text.style.fontWeight = "bold";
  text.style.marginLeft = "35px";
  text.innerHTML = "Action Successfully Executed";
  toastContainer.appendChild(text);
  
          document.body.appendChild(toastContainer);
    
      setTimeout(function() {
        toastContainer.style.display = "block";
        toastContainer.style.opacity = "1";
      }, 0);
    
      setTimeout(function() {
        toastContainer.style.opacity = "0";
      }, 5000);
    
      setTimeout(function() {
        toastContainer.style.display = "none";
      }, 5500);
      Fdebug();
  
    }
    
  
  //The Update toast
  function showToastUpdate() {
  var toastContainer = document.createElement("div");
  toastContainer.style.position = "fixed";
  toastContainer.style.bottom = "5px";
  toastContainer.style.right = "5px";
  toastContainer.style.backgroundColor = "white";
  toastContainer.style.color = "#141414";
  toastContainer.style.padding = "5px";
  toastContainer.style.border = "2px solid #f22c2c";
  toastContainer.style.borderRadius = "5px";
  toastContainer.style.boxShadow = "2px 2px 10px rgba(0, 0, 0, 0.5)";
  toastContainer.style.display = "none";
  toastContainer.style.zIndex = "999";
  toastContainer.style.transition = "opacity 0.5s ease-in-out";
  toastContainer.style.opacity = "0";
  toastContainer.style.display = "flex";
  toastContainer.style.alignItems = "center";
  var statusBar = document.createElement("div");
  statusBar.style.width = "100%";
  statusBar.style.height = "3px";
  statusBar.style.backgroundColor = "black";
  statusBar.style.position = "absolute";
  statusBar.style.bottom = "0";
  statusBar.style.left = "0";
  statusBar.style.transition = "width 5s ease-in-out";
  statusBar.style.width = "0%";
  toastContainer.appendChild(statusBar);
  setTimeout(function() {
    statusBar.style.width = "100%";
  }, 0);
  
  var closeButton = document.createElement("button");
  closeButton.style.border = "none";
  closeButton.style.background = "none";
  closeButton.style.top = "5px";
  closeButton.style.right = "5px";
  closeButton.style.fontWeight = "bold";
  closeButton.style.fontSize = "16px";
  closeButton.style.marginLeft = "-2px";
  closeButton.style.marginRight = "0px";
  closeButton.innerHTML = "X";
  toastContainer.appendChild(closeButton);
  closeButton.addEventListener("click", function() {
    toastContainer.style.opacity = "0";
    setTimeout(function() {
      toastContainer.style.display = "none";
    }, 500);
  });
  var icon = document.createElement("img");
  icon.src = "https://media.discordapp.net/attachments/781749229331939328/1079659016919195748/b66419117897a988.png?width=1190&height=1189";
  icon.style.width = "23px";
  icon.style.height = "23px";
  icon.style.borderRadius = "50%";
  icon.style.marginRight = "-30px";
  icon.style.marginBottom = "-5px";
  toastContainer.appendChild(icon);
  
  // Update client message
  var text = document.createElement("span");
  text.style.fontWeight = "bold";
  text.style.marginLeft = "35px";
  text.innerHTML = "New update detected, refresh BC to update to V2.0.7";
  toastContainer.appendChild(text);
  
  document.body.appendChild(toastContainer);
  
  setTimeout(function() {
    toastContainer.style.display = "block";
    toastContainer.style.opacity = "1";
  }, 0);
  
  setTimeout(function() {
    toastContainer.style.opacity = "0";
  }, 5000000);
  
  setTimeout(function() {
    toastContainer.style.display = "none";
  }, 5500000);
  
  }
  
    // End of Update Toast________________
  
  
    //  URL of the update page
  const url = 'https://raw.githubusercontent.com/BCMS7/BCME-External/main/updatemanager.js';
  const maxVersion = 15;
  let alertTriggered = false;
  function checkVersion() {
    fetch(url)
      .then(response => response.text())
      .then(version => {
        if (parseInt(version) > maxVersion && !alertTriggered) {
          showToastUpdate();
          alertTriggered = true;
        }
      })
      .catch(error => console.error(error));
  }
  // Check for updates every 5 seconds
  setInterval(checkVersion, 5000);
  }
  })