मीडियाविकि:Common.js: संशोधनहरू बीचको भिन्नता

परमेश्वरको मण्डली विश्वकोशबाट
अन्वेषणमा जानुहाेस् खाेजमा जानुहाेस्
कुनै सम्पादन सारांश छैन
कुनै सम्पादन सारांश छैन
पङ्क्ति १: पङ्क्ति १:
if(!mw.config.get('wgUserId')){
if (!mw.config.get("wgUserId")) {
var currentUrl = window.location.href;
  var currentUrl = window.location.href;
var commJs = currentUrl.includes('Common.js');
  var commJs = currentUrl.includes("Common.js");
var commCss = currentUrl.includes('Common.css');
  var commCss = currentUrl.includes("Common.css");
var vectorJs = currentUrl.includes('Vector.js');
  var vectorJs = currentUrl.includes("Vector.js");
var vectorCss = currentUrl.includes('Vector.css');  
  var vectorCss = currentUrl.includes("Vector.css");
if(commJs || commCss || vectorJs || vectorCss ){
  if (commJs || commCss || vectorJs || vectorCss) {
window.location.href = '/index.php';
    window.location.href = "/index.php";
}
  }
  // 도구 메뉴들 숨김(사이드바);
  $pTb = document.getElementById("p-tb");
  if ($pTb) $pTb.parentElement.removeChild($pTb);


// 문서의 역사롤 봅니다. (hidden 시킴)
  // 문서의 역사롤 봅니다. (hidden 시킴)
var $lastModifiedBar = document.querySelector('.last-modified-bar');
  var $lastModifiedBar = document.querySelector(".last-modified-bar");
if($lastModifiedBar) $lastModifiedBar.parentElement.removeChild($lastModifiedBar);
  if ($lastModifiedBar)
    $lastModifiedBar.parentElement.removeChild($lastModifiedBar);


//파일중복 메세지 제거
  //파일중복 메세지 제거
var $duplicates = document.getElementById('mw-imagepage-section-duplicates');
  var $duplicates = document.getElementById("mw-imagepage-section-duplicates");
if($duplicates) $duplicates.parentElement.removeChild($duplicates);
  if ($duplicates) $duplicates.parentElement.removeChild($duplicates);
}
}


/* 모바일 모드 문서 언어선택기 삭제*/
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
var $mobileLanguageSelector = document.getElementById('language-selector');
//Google Analytics
if ($mobileLanguageSelector) $mobileLanguageSelector.parentElement.removeChild($mobileLanguageSelector);
var GoogleCdn = document.createElement("script");
GoogleCdn.src = "https://www.googletagmanager.com/gtag/js?id=G-MN2WCQEXLW";
document.body.appendChild(GoogleCdn);
window.dataLayer = window.dataLayer || [];
function gtag() {
  dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "G-MN2WCQEXLW");


/* TOP 버튼 */
/* TOP 버튼 */
var topButton = document.createElement('div');
var topButton = document.createElement("div");
topButton.id = 'top-button';
topButton.id = "top-button";


document.body.appendChild(topButton);
document.body.appendChild(topButton);
window.addEventListener('scroll', function (e) {
window.addEventListener("scroll", function (e) {
    if (window.scrollY > 300) {
  if (window.scrollY > 300) {
        topButton.classList.add('active');
    topButton.classList.add("active");
    } else {
  } else {
        topButton.classList.remove('active');
    topButton.classList.remove("active");
    }
  }
});
});
topButton.addEventListener('click', function (e) {
topButton.addEventListener("click", function (e) {
    try {
  try {
        window.scrollTo({
    window.scrollTo({
            top: 0,
      top: 0,
            left: 0,
      left: 0,
            behavior: 'smooth',
      behavior: "smooth",
        });
    });
    } catch (e) {
  } catch (e) {
        window.scrollTo(0, 0);
    window.scrollTo(0, 0);
    }
  }
});
});
/* 대문 섹션 토글 */
/* 대문 섹션 토글 */
if (mw.config.get('wgPageName') == '대문' || mw.config.get('wgPageName') == '대문테스트') {
if (
    var titles = document.querySelectorAll('.cog-box-title');
  mw.config.get("wgPageName") == "대문" ||
    for (var i = 0; i < titles.length; i++) {
  mw.config.get("wgPageName") == "대문테스트"
        titles[i].addEventListener('click', function (e) {
) {
            if (e.currentTarget.classList.contains('open')) {
  var titles = document.querySelectorAll(".cog-box-title");
                e.currentTarget.classList.remove('open');
  for (var i = 0; i < titles.length; i++) {
            } else {
    titles[i].addEventListener("click", function (e) {
                e.currentTarget.classList.add('open');
      if (e.currentTarget.classList.contains("open")) {
            }
        e.currentTarget.classList.remove("open");
        });
      } else {
    }
        e.currentTarget.classList.add("open");
      }
    });
  }
}
}


/*모든 문서 */
/*모든 문서 */
if (mw.config.get('wgPageName').toLowerCase() == 'list_of_all_documents') {
if (mw.config.get("wgPageName").toLowerCase() == "list_of_all_documents") {
    var list = document.querySelectorAll('.mw-allpages-body li');
  var list = document.querySelectorAll(".mw-allpages-body li");
    for (var i = 0; i < list.length; i++) {
  for (var i = 0; i < list.length; i++) {
        var title = list[i].querySelector('a').title;
    var title = list[i].querySelector("a").title;
        if (title.indexOf(':') != -1) {
    if (title.indexOf(":") != -1) {
            list[i].parentNode.removeChild(list[i]);
      list[i].parentNode.removeChild(list[i]);
        }
     }
     }
    document.querySelector('.cog-commonpages').style.display = '';
  }
  document.querySelector(".cog-commonpages").style.display = "";
}
}


/* 각주 팝업창 위치 보정 */
/* 각주 팝업창 위치 보정 */
document.body.addEventListener(
var observer = new MutationObserver(function (mutationList) {
     'DOMNodeInserted',
  mutationList.forEach(function (mutation) {
    function (e) {
     mutation.addedNodes.forEach(function (node) {
        if (e.target.classList && e.target.classList.contains('mwe-popups')) {
      if (
            requestAnimationFrame(function () {
        node.classList &&
                var bodyLeft = document.body.getBoundingClientRect().left;
        (node.classList.contains("mwe-popups") ||
                var left = parseInt(window.getComputedStyle(e.target).left);
          node.classList.contains("rt-tooltip"))
                e.target.style.left = left - bodyLeft + 'px';
      ) {
            });
        requestAnimationFrame(function () {
        }
          var bodyLeft = document.body.getBoundingClientRect().left;
     },
          var left = parseInt(window.getComputedStyle(node).left);
    false
          node.style.left = left - bodyLeft + "px";
);
        });
      }
     });
  });
});
// 감시할 대상 설정
observer.observe(document.body, {
  childList: true,
  subtree: true,
});


/* 우클릭 방지 */
/* 우클릭 방지 */
if (mw.config.get('wgUserName') == null) {
if (mw.config.get("wgUserName") == null) {
window.oncontextmenu = function (e) {
  window.oncontextmenu = function (e) {
    return e.preventDefault();
    return e.preventDefault();
};
  };
window.onselectstart = function (e) {
  window.onselectstart = function (e) {
    return e.preventDefault();
    return e.preventDefault();
};
  };
}
}
/* 존재하지 않는 문서 페이지의 '기록' 링크 삭제 */
/* 존재하지 않는 문서 페이지의 '기록' 링크 삭제 */
if (mw.config.get('wgUserId') == null && document.querySelector('.plainlinks a')) {
if (
    document.querySelector('.plainlinks a').removeAttribute('href');
  mw.config.get("wgUserId") == null &&
    document.querySelector('.plainlinks a').classList.add('disable');
  document.querySelector(".plainlinks a")
) {
  document.querySelector(".plainlinks a").removeAttribute("href");
  document.querySelector(".plainlinks a").classList.add("disable");
}
}


// 대문 공유 버튼
// 대문 공유 버튼
var sharebox = document.querySelector('.wikishare_toolbox');
var sharebox = document.querySelector(".wikishare_toolbox");
if (sharebox) {
if (sharebox) {
    sharebox.classList.add('a2a_kit_size_20');
  sharebox.classList.add("a2a_kit_size_20");
    sharebox.classList.add('a2a_kit');
  sharebox.classList.add("a2a_kit");
    var shares = ['Facebook', 'Twitter', 'Email', 'Line', 'Kakao', 'SMS'];
  var shares = ["Facebook", "Twitter", "Email", "Line", "Kakao", "SMS"];
    for (var i in shares) {
  for (var i in shares) {
        var elem = document.querySelector('[title="Share on ' + shares[i] + '"] a');
    var elem = document.querySelector('[title="Share on ' + shares[i] + '"] a');
        elem.href = '';
    elem.href = "";
        elem.classList.add('a2a_button_' + shares[i].toLowerCase());
    elem.classList.add("a2a_button_" + shares[i].toLowerCase());
    }
  }
    //네팔어 faceBook 공유버튼 깨짐
  document.querySelector('[title="Share on KakaoTalk"] a').href = "#";
//document.querySelector('[title="Share on Facebook"] a').innerHTML = '<img class="wikishare_icon" src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/51/Facebook_f_logo_%282019%29.svg/40px-Facebook_f_logo_%282019%29.svg.png" width="20px">';
  document
//const brokenElem = document.querySelector('.wikishare_toolbox > a');
     .querySelector('[title="Share on KakaoTalk"] a')
    //brokenElem.remove();
     .removeAttribute("target");
      
    document.querySelector('[title="Share on KakaoTalk"] a').href = '#';
     document.querySelector('[title="Share on KakaoTalk"] a').removeAttribute('target');


    var share_cdn = document.createElement('script');
  var share_cdn = document.createElement("script");
    share_cdn.src = 'https://static.addtoany.com/menu/page.js';
  share_cdn.src = "https://static.addtoany.com/menu/page.js";
    var kakao_cdn = document.createElement('script');
  var kakao_cdn = document.createElement("script");
    kakao_cdn.src = 'https://developers.kakao.com/sdk/js/kakao.min.js';
  kakao_cdn.src = "https://developers.kakao.com/sdk/js/kakao.min.js";
    document.body.appendChild(share_cdn);
  document.body.appendChild(share_cdn);
    document.body.appendChild(kakao_cdn);
  document.body.appendChild(kakao_cdn);


    // 페이지 로딩 이후 초기화해야할 내용 정의
  // 페이지 로딩 이후 초기화해야할 내용 정의
    initScript();
  initScript();
    function initScript() {
  function initScript() {
        var retry = false;
    var retry = false;


        // 카카오 링크 초기화
    // 카카오 링크 초기화
        if (window.initKakaoLink != true) {
    if (window.initKakaoLink != true) {
            var $kakao = document.querySelector('[title="Share on KakaoTalk"]');
      var $kakao = document.querySelector('[title="Share on KakaoTalk"]');
            if (window.Kakao && $kakao) {
      if (window.Kakao && $kakao) {
                // 사용할 앱의 JavaScript 키를 설정해 주세요.
        // 사용할 앱의 JavaScript 키를 설정해 주세요.
                Kakao.init('214de4d25d41a7b837b7bbeb75631c90');
        Kakao.init("214de4d25d41a7b837b7bbeb75631c90");
                $kakao.children[0].style.display = 'inline';
        $kakao.children[0].style.display = "inline";
                $kakao.onclick = sendScrap; // 카카오 Link 공유 API 사용
        $kakao.onclick = sendScrap; // 카카오 Link 공유 API 사용
                window.initKakaoLink = true;
        window.initKakaoLink = true;
            } else retry = true;
      } else retry = true;
        }
    }


        // 링크 복사 초기화
    // 링크 복사 초기화
        if (window.initCopyLink != true) {
    if (window.initCopyLink != true) {
            var $copy = document.querySelector('.wikishare_button_Copy');
      var $copy = document.querySelector(".wikishare_button_Copy");
            if ($copy) {
      if ($copy) {
                $copy.style.display = 'inline';
        $copy.style.display = "inline";
                $copy.addEventListener('click', function (e) {
        $copy.addEventListener("click", function (e) {
                    copyStringToClipboard(decodeURI(location.href));
          copyStringToClipboard(decodeURI(location.href));
                    alert('Saved the link to the clipboard.');
          alert("Saved the link to the clipboard.");
                    e.preventDefault();
          e.preventDefault();
                });
        });
                window.initCopyLink = true;
        window.initCopyLink = true;
            } else retry = true;
      } else retry = true;
        }
    }


        // 애널리틱스
    // 애널리틱스
        if (window.initWcs != true) {
    if (window.initWcs != true) {
            if (window.wcs) {
      if (window.wcs) {
                wcs_do();
        wcs_do();
                window.initWcs = true;
        window.initWcs = true;
            } else retry = true;
      } else retry = true;
        }
    }


        if (retry) setTimeout(initScript, 300);
    if (retry) setTimeout(initScript, 300);
    }
  }
}
}


// 문자열을 클립보드에 저장
// 문자열을 클립보드에 저장
function copyStringToClipboard(str) {
function copyStringToClipboard(str) {
    var el = document.createElement('textarea');
  var el = document.createElement("textarea");
    el.value = str;
  el.value = str;
    el.setAttribute('readonly', '');
  el.setAttribute("readonly", "");
    el.style = { position: 'absolute', left: '-9999px' };
  el.style = { position: "absolute", left: "-9999px" };
    document.body.appendChild(el);
  document.body.appendChild(el);
    el.select();
  el.select();
    document.execCommand('copy');
  document.execCommand("copy");
    document.body.removeChild(el);
  document.body.removeChild(el);
}
}


function sendScrap() {
function sendScrap() {
    // 카카오 Link 공유 API 사용
  // 카카오 Link 공유 API 사용
    Kakao.Link.sendScrap({
  Kakao.Link.sendScrap({
        requestUrl: location.href,
    requestUrl: location.href,
        templateId: 91817,
    templateId: 91817,
        templateArgs: {
    templateArgs: {
            TITLE: og('title', 'Church of God Knowledge Encyclopedia'),
      TITLE: og("title", "Church of God Knowledge Encyclopedia"),
            DESC: og('description'),
      DESC: og("description"),
            THUMB: thumb(),
      THUMB: thumb(),
            PAGE: path(),
      PAGE: path(),
        },
    },
    });
  });
    function og(name, defaultVal) {
  function og(name, defaultVal) {
        var $meta = document.querySelector('meta[property="og:' + name + '"]');
    var $meta = document.querySelector('meta[property="og:' + name + '"]');
        if ($meta) return $meta.getAttribute('content');
    if ($meta) return $meta.getAttribute("content");
        else return defaultVal ? defaultVal : '';
    else return defaultVal ? defaultVal : "";
    }
  }
    function thumb() {
  function thumb() {
        var img = og('image');
    var img = og("image");
        if (!img) {
    if (!img) {
            var $img = document.querySelector('img[src]');
      var $img = document.querySelector("img[src]");
            if ($img) {
      if ($img) {
                img = $img.src;
        img = $img.src;
            }
      }
        }
        if (img.indexOf('http') != 0) img = location.origin + (img[0] == '/' ? img : '/' + img);
        return img;
    }
    function path() {
        if (location.pathname[0] == '/') return location.pathname.substring(1) + location.search;
        else return location.pathname + location.search;
     }
     }
    if (img.indexOf("http") != 0)
      img = location.origin + (img[0] == "/" ? img : "/" + img);
    return img;
  }
  function path() {
    if (location.pathname[0] == "/")
      return location.pathname.substring(1) + location.search;
    else return location.pathname + location.search;
  }
}
}


// 앨범 레이아웃 보정
// 앨범 레이아웃 보정
updateAllAlbum();
updateAllAlbum();
window.addEventListener('load', updateAllAlbum);
window.addEventListener("load", updateAllAlbum);
window.addEventListener('resize', updateAllAlbum);
window.addEventListener("resize", updateAllAlbum);
function updateAllAlbum() {
function updateAllAlbum() {
    var $albums = document.querySelectorAll('.custom-album');
  var $albums = document.querySelectorAll(".custom-album");
    for (var i = 0; i < $albums.length; i++) {
  for (var i = 0; i < $albums.length; i++) {
        updateAlbum($albums[i]);
    updateAlbum($albums[i]);
    }
  }
}
}
function updateAlbum($elem) {
function updateAlbum($elem) {
    var lineMax = 3;
  var lineMax = 3;
    for (var i = 0; i < $elem.classList.length; i++) {
  for (var i = 0; i < $elem.classList.length; i++) {
        if ($elem.classList[i].indexOf('line-max-') == 0) {
    if ($elem.classList[i].indexOf("line-max-") == 0) {
            lineMax = Number($elem.classList[i].replace('line-max-', ''));
      lineMax = Number($elem.classList[i].replace("line-max-", ""));
        }
     }
     }
  }


    var totalWidth = $elem.clientWidth;
  var totalWidth = $elem.clientWidth;


    if ($elem.children.length > 0) {
  if ($elem.children.length > 0) {
        for (var i = $elem.children.length - 1; i >= 0; i--) {
    for (var i = $elem.children.length - 1; i >= 0; i--) {
            if (!$elem.children[i].classList.contains('albumitem')) {
      if (!$elem.children[i].classList.contains("albumitem")) {
                $elem.children[i].remove();
        $elem.children[i].remove();
                continue;
        continue;
            }
      }
            $elem.children[i].style.width = '';
      $elem.children[i].style.width = "";
            $elem.children[i].style.height = '';
      $elem.children[i].style.height = "";
        }
    }


        if (window.innerWidth < 720) return;
    if (window.innerWidth < 720) return;


        var lineTotalRatio = [];
    var lineTotalRatio = [];
        for (var i = 0; i < $elem.children.length; i++) {
    for (var i = 0; i < $elem.children.length; i++) {
            var lineIdx = Math.floor(i / lineMax);
      var lineIdx = Math.floor(i / lineMax);
            var $img = $elem.children[i].querySelector('img');
      var $img = $elem.children[i].querySelector("img");


            if (!$img || $img.naturalWidth == 0) continue;
      if (!$img || $img.naturalWidth == 0) continue;


            if (lineTotalRatio[lineIdx] == undefined) {
      if (lineTotalRatio[lineIdx] == undefined) {
                lineTotalRatio[lineIdx] = 0;
        lineTotalRatio[lineIdx] = 0;
            }
      }


            lineTotalRatio[lineIdx] += $img.naturalWidth / $img.naturalHeight;
      lineTotalRatio[lineIdx] += $img.naturalWidth / $img.naturalHeight;
        }
    }


        for (var i = 0; i < $elem.children.length; i++) {
    for (var i = 0; i < $elem.children.length; i++) {
            var totalRatio = lineTotalRatio[Math.floor(i / lineMax)];
      var totalRatio = lineTotalRatio[Math.floor(i / lineMax)];
            var $img = $elem.children[i].querySelector('img');
      var $img = $elem.children[i].querySelector("img");


            if (!$img || $img.naturalWidth == 0) continue;
      if (!$img || $img.naturalWidth == 0) continue;


            var ratio = $img.naturalWidth / $img.naturalHeight;
      var ratio = $img.naturalWidth / $img.naturalHeight;
            var width = (ratio / totalRatio) * (totalWidth - 6 * lineMax) + 6;
      var width = (ratio / totalRatio) * (totalWidth - 6 * lineMax) + 6;
            $elem.children[i].style.width = (width / totalWidth) * 100 + '%';
      $elem.children[i].style.width = (width / totalWidth) * 100 + "%";
        }
     }
     }
  }
}
}


//넘겨주기 문서를 숨깁니다.
var redirectList = document.querySelectorAll(
  ".mw-parser-output li.allpagesredirect"
);
for (var i = 0; i < redirectList.length; i++) {
  redirectList[i].style.display = "none";
}


// 데스크탑 언어
// 이미지문서에서 commons 라이센스 관련 링크를 숨긴다.
var langDiv = document.getElementById('right-navigation');
var $sharedUploadNotice = document.querySelector(".sharedUploadNotice p");
if(langDiv){
if ($sharedUploadNotice) {
var navHTML = '<nav id="p-cactions" class="mw-portlet mw-portlet-cactions vector-menu-dropdown-noicon vector-menu vector-menu-dropdown" aria-labelledby="p-cactions-label" role="navigation">' +
  $sharedUploadNotice.parentElement.removeChild($sharedUploadNotice);
'<input type="checkbox" id="p-cactions-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-cactions" class="vector-menu-checkbox" aria-labelledby="p-cactions-label">' +
}
'<label id="p-cactions-label" aria-label="" class="vector-menu-heading">' +
// origin file 영역 숨김.
  '<span class="select-language"></span>' +
var $fullMedia = document.querySelector(".fullMedia p");
  '<span class="vector-menu-heading-label">Language</span>' +
if ($fullMedia) {
'</label>' +
  $fullMedia.parentElement.removeChild($fullMedia);
'<div class="vector-menu-content">' +
  '<ul class="vector-menu-content-list">' +
'<li class="mw-list-item"><a href="https://churchofgod.wiki" title="하나님의 교회 지식사전"><span>Korean</span></a></li>' +
    '<li class="mw-list-item"><a href="https://en.churchofgod.wiki" title="Church of God Knowledge Encyclopedia"><span>English</span></a></li>' +
    '<li class="mw-list-item"><a href="https://es.churchofgod.wiki" title="ChurchEnciclopedia de conocimiento de la Iglesia de Dios"><span>Spanish</span></a></li>' +
    '<li class="mw-list-item"><a href="https://vi.churchofgod.wiki" title="Từ điển tri thức Hội Thánh của Đức Chúa Trời"><span>Vietnamese</span></a></li>' +
  '</ul>' +
'</div>' +
'</nav>';
langDiv.insertAdjacentHTML('afterbegin', navHTML);
}
}

२३:३७, १ डिसेम्बर २०२४ जस्तै गरी पुनरावलोकन

if (!mw.config.get("wgUserId")) {
  var currentUrl = window.location.href;
  var commJs = currentUrl.includes("Common.js");
  var commCss = currentUrl.includes("Common.css");
  var vectorJs = currentUrl.includes("Vector.js");
  var vectorCss = currentUrl.includes("Vector.css");
  if (commJs || commCss || vectorJs || vectorCss) {
    window.location.href = "/index.php";
  }
  // 도구 메뉴들 숨김(사이드바);
  $pTb = document.getElementById("p-tb");
  if ($pTb) $pTb.parentElement.removeChild($pTb);

  // 문서의 역사롤 봅니다. (hidden 시킴)
  var $lastModifiedBar = document.querySelector(".last-modified-bar");
  if ($lastModifiedBar)
    $lastModifiedBar.parentElement.removeChild($lastModifiedBar);

  //파일중복 메세지 제거
  var $duplicates = document.getElementById("mw-imagepage-section-duplicates");
  if ($duplicates) $duplicates.parentElement.removeChild($duplicates);
}

/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
//Google Analytics
var GoogleCdn = document.createElement("script");
GoogleCdn.src = "https://www.googletagmanager.com/gtag/js?id=G-MN2WCQEXLW";
document.body.appendChild(GoogleCdn);
window.dataLayer = window.dataLayer || [];
function gtag() {
  dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "G-MN2WCQEXLW");

/* TOP 버튼 */
var topButton = document.createElement("div");
topButton.id = "top-button";

document.body.appendChild(topButton);
window.addEventListener("scroll", function (e) {
  if (window.scrollY > 300) {
    topButton.classList.add("active");
  } else {
    topButton.classList.remove("active");
  }
});
topButton.addEventListener("click", function (e) {
  try {
    window.scrollTo({
      top: 0,
      left: 0,
      behavior: "smooth",
    });
  } catch (e) {
    window.scrollTo(0, 0);
  }
});
/* 대문 섹션 토글 */
if (
  mw.config.get("wgPageName") == "대문" ||
  mw.config.get("wgPageName") == "대문테스트"
) {
  var titles = document.querySelectorAll(".cog-box-title");
  for (var i = 0; i < titles.length; i++) {
    titles[i].addEventListener("click", function (e) {
      if (e.currentTarget.classList.contains("open")) {
        e.currentTarget.classList.remove("open");
      } else {
        e.currentTarget.classList.add("open");
      }
    });
  }
}

/*모든 문서 */
if (mw.config.get("wgPageName").toLowerCase() == "list_of_all_documents") {
  var list = document.querySelectorAll(".mw-allpages-body li");
  for (var i = 0; i < list.length; i++) {
    var title = list[i].querySelector("a").title;
    if (title.indexOf(":") != -1) {
      list[i].parentNode.removeChild(list[i]);
    }
  }
  document.querySelector(".cog-commonpages").style.display = "";
}

/* 각주 팝업창 위치 보정 */
var observer = new MutationObserver(function (mutationList) {
  mutationList.forEach(function (mutation) {
    mutation.addedNodes.forEach(function (node) {
      if (
        node.classList &&
        (node.classList.contains("mwe-popups") ||
          node.classList.contains("rt-tooltip"))
      ) {
        requestAnimationFrame(function () {
          var bodyLeft = document.body.getBoundingClientRect().left;
          var left = parseInt(window.getComputedStyle(node).left);
          node.style.left = left - bodyLeft + "px";
        });
      }
    });
  });
});
// 감시할 대상 설정
observer.observe(document.body, {
  childList: true,
  subtree: true,
});

/* 우클릭 방지 */
if (mw.config.get("wgUserName") == null) {
  window.oncontextmenu = function (e) {
    return e.preventDefault();
  };
  window.onselectstart = function (e) {
    return e.preventDefault();
  };
}
/* 존재하지 않는 문서 페이지의 '기록' 링크 삭제 */
if (
  mw.config.get("wgUserId") == null &&
  document.querySelector(".plainlinks a")
) {
  document.querySelector(".plainlinks a").removeAttribute("href");
  document.querySelector(".plainlinks a").classList.add("disable");
}

// 대문 공유 버튼
var sharebox = document.querySelector(".wikishare_toolbox");
if (sharebox) {
  sharebox.classList.add("a2a_kit_size_20");
  sharebox.classList.add("a2a_kit");
  var shares = ["Facebook", "Twitter", "Email", "Line", "Kakao", "SMS"];
  for (var i in shares) {
    var elem = document.querySelector('[title="Share on ' + shares[i] + '"] a');
    elem.href = "";
    elem.classList.add("a2a_button_" + shares[i].toLowerCase());
  }
  document.querySelector('[title="Share on KakaoTalk"] a').href = "#";
  document
    .querySelector('[title="Share on KakaoTalk"] a')
    .removeAttribute("target");

  var share_cdn = document.createElement("script");
  share_cdn.src = "https://static.addtoany.com/menu/page.js";
  var kakao_cdn = document.createElement("script");
  kakao_cdn.src = "https://developers.kakao.com/sdk/js/kakao.min.js";
  document.body.appendChild(share_cdn);
  document.body.appendChild(kakao_cdn);

  // 페이지 로딩 이후 초기화해야할 내용 정의
  initScript();
  function initScript() {
    var retry = false;

    // 카카오 링크 초기화
    if (window.initKakaoLink != true) {
      var $kakao = document.querySelector('[title="Share on KakaoTalk"]');
      if (window.Kakao && $kakao) {
        // 사용할 앱의 JavaScript 키를 설정해 주세요.
        Kakao.init("214de4d25d41a7b837b7bbeb75631c90");
        $kakao.children[0].style.display = "inline";
        $kakao.onclick = sendScrap; // 카카오 Link 공유 API 사용
        window.initKakaoLink = true;
      } else retry = true;
    }

    // 링크 복사 초기화
    if (window.initCopyLink != true) {
      var $copy = document.querySelector(".wikishare_button_Copy");
      if ($copy) {
        $copy.style.display = "inline";
        $copy.addEventListener("click", function (e) {
          copyStringToClipboard(decodeURI(location.href));
          alert("Saved the link to the clipboard.");
          e.preventDefault();
        });
        window.initCopyLink = true;
      } else retry = true;
    }

    // 애널리틱스
    if (window.initWcs != true) {
      if (window.wcs) {
        wcs_do();
        window.initWcs = true;
      } else retry = true;
    }

    if (retry) setTimeout(initScript, 300);
  }
}

// 문자열을 클립보드에 저장
function copyStringToClipboard(str) {
  var el = document.createElement("textarea");
  el.value = str;
  el.setAttribute("readonly", "");
  el.style = { position: "absolute", left: "-9999px" };
  document.body.appendChild(el);
  el.select();
  document.execCommand("copy");
  document.body.removeChild(el);
}

function sendScrap() {
  // 카카오 Link 공유 API 사용
  Kakao.Link.sendScrap({
    requestUrl: location.href,
    templateId: 91817,
    templateArgs: {
      TITLE: og("title", "Church of God Knowledge Encyclopedia"),
      DESC: og("description"),
      THUMB: thumb(),
      PAGE: path(),
    },
  });
  function og(name, defaultVal) {
    var $meta = document.querySelector('meta[property="og:' + name + '"]');
    if ($meta) return $meta.getAttribute("content");
    else return defaultVal ? defaultVal : "";
  }
  function thumb() {
    var img = og("image");
    if (!img) {
      var $img = document.querySelector("img[src]");
      if ($img) {
        img = $img.src;
      }
    }
    if (img.indexOf("http") != 0)
      img = location.origin + (img[0] == "/" ? img : "/" + img);
    return img;
  }
  function path() {
    if (location.pathname[0] == "/")
      return location.pathname.substring(1) + location.search;
    else return location.pathname + location.search;
  }
}

// 앨범 레이아웃 보정
updateAllAlbum();
window.addEventListener("load", updateAllAlbum);
window.addEventListener("resize", updateAllAlbum);
function updateAllAlbum() {
  var $albums = document.querySelectorAll(".custom-album");
  for (var i = 0; i < $albums.length; i++) {
    updateAlbum($albums[i]);
  }
}
function updateAlbum($elem) {
  var lineMax = 3;
  for (var i = 0; i < $elem.classList.length; i++) {
    if ($elem.classList[i].indexOf("line-max-") == 0) {
      lineMax = Number($elem.classList[i].replace("line-max-", ""));
    }
  }

  var totalWidth = $elem.clientWidth;

  if ($elem.children.length > 0) {
    for (var i = $elem.children.length - 1; i >= 0; i--) {
      if (!$elem.children[i].classList.contains("albumitem")) {
        $elem.children[i].remove();
        continue;
      }
      $elem.children[i].style.width = "";
      $elem.children[i].style.height = "";
    }

    if (window.innerWidth < 720) return;

    var lineTotalRatio = [];
    for (var i = 0; i < $elem.children.length; i++) {
      var lineIdx = Math.floor(i / lineMax);
      var $img = $elem.children[i].querySelector("img");

      if (!$img || $img.naturalWidth == 0) continue;

      if (lineTotalRatio[lineIdx] == undefined) {
        lineTotalRatio[lineIdx] = 0;
      }

      lineTotalRatio[lineIdx] += $img.naturalWidth / $img.naturalHeight;
    }

    for (var i = 0; i < $elem.children.length; i++) {
      var totalRatio = lineTotalRatio[Math.floor(i / lineMax)];
      var $img = $elem.children[i].querySelector("img");

      if (!$img || $img.naturalWidth == 0) continue;

      var ratio = $img.naturalWidth / $img.naturalHeight;
      var width = (ratio / totalRatio) * (totalWidth - 6 * lineMax) + 6;
      $elem.children[i].style.width = (width / totalWidth) * 100 + "%";
    }
  }
}

//넘겨주기 문서를 숨깁니다.
var redirectList = document.querySelectorAll(
  ".mw-parser-output li.allpagesredirect"
);
for (var i = 0; i < redirectList.length; i++) {
  redirectList[i].style.display = "none";
}

// 이미지문서에서 commons 라이센스 관련 링크를 숨긴다.
var $sharedUploadNotice = document.querySelector(".sharedUploadNotice p");
if ($sharedUploadNotice) {
  $sharedUploadNotice.parentElement.removeChild($sharedUploadNotice);
}
// origin file 영역 숨김.
var $fullMedia = document.querySelector(".fullMedia p");
if ($fullMedia) {
  $fullMedia.parentElement.removeChild($fullMedia);
}