MediaWiki:Common.js: Difference between revisions

From Obsidian Scheduler
Jump to navigationJump to search
No edit summary
No edit summary
Line 14: Line 14:
   else if(window.addEventListener) window.addEventListener('load', bcLoad, false);
   else if(window.addEventListener) window.addEventListener('load', bcLoad, false);
   else window.attachEvent('onload', bcLoad);
   else window.attachEvent('onload', bcLoad);
function waitForElementToDisplay(selector, callback, checkFrequencyInMs, timeoutInMs) {
  var startTimeInMs = Date.now();
  (function loopSearch() {
    if (document.querySelector(selector) != null) {
      callback();
      return;
    }
    else {
      setTimeout(function () {
        if (timeoutInMs && Date.now() - startTimeInMs > timeoutInMs)
          return;
        loopSearch();
      }, checkFrequencyInMs);
    }
  })();
}
waitForElementToDisplay("p-search",function(){
var navColumn = document.getElementById('p-search');
console.log(navColumn.innerHMTL);
var chatDiv = document.createElement('div');
chatDiv.innerHTML = '<!-- BoldChat Live Chat Button HTML v5.00 (Type=Web,ChatButton=My Chat Button,Website=- None -) -->\r\n' +
'<div style="text-align: center; white-space: nowrap;">\r\n' +
'<script type="text/javascript">\r\n' +
'  var bccbId = Math.random(); document.write(unescape(\'%3Cdiv id=\' + bccbId + \'%3E%3C/div%3E\'));\r\n' +
'  window._bcvma = window._bcvma || [];\r\n' +
'  _bcvma.push(["setAccountID", "420408690637749684"]);\r\n' +
'  _bcvma.push(["addStatic", {type: "chat", bdid: "416622039216493532", id: bccbId}]);\r\n' +
'  var bcLoad = function(){\r\n' +
' if(window.bcLoaded) return; window.bcLoaded = true;\r\n' +
' var vms = document.createElement("script"); vms.type = "text/javascript"; vms.async = true;\r\n' +
' vms.src = "https://vmss.boldchat.com/aid/420408690637749684/bc.vms4/vms.js";\r\n' +
' var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(vms, s);\r\n' +
' };\r\n' +
'  if(window.pageViewer && pageViewer.load) pageViewer.load();\r\n' +
'  else if(document.readyState=="complete") bcLoad();\r\n' +
'  else if(window.addEventListener) window.addEventListener(\'load\', bcLoad, false);\r\n' +
'  else window.attachEvent(\'onload\', bcLoad);\r\n' +
'</script>\r\n' +
'</div>\r\n' +
'<!-- /BoldChat Live Chat Button HTML v5.00 -->';
navColumn.append(chatDiv);
},1000,9000);

Revision as of 17:47, 30 March 2021


  window._bcvma = window._bcvma || [];
  _bcvma.push(["setAccountID", "420408690637749684"]);
  _bcvma.push(["setParameter", "InvitationID", "416622039416554093"]);
  _bcvma.push(["pageViewed"]);
  var bcLoad = function(){
    if(window.bcLoaded) return; window.bcLoaded = true;
    var vms = document.createElement("script"); vms.type = "text/javascript"; vms.async = true;
    vms.src = "https://vmss.boldchat.com/aid/420408690637749684/bc.vms4/vms.js";
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(vms, s);
  };
  if(window.pageViewer && pageViewer.load) pageViewer.load();
  else if(document.readyState=="complete") bcLoad();
  else if(window.addEventListener) window.addEventListener('load', bcLoad, false);
  else window.attachEvent('onload', bcLoad);