사용자:하늘/light.js: 두 판 사이의 차이

편집 요약 없음
(문서를 비움)
태그: 비우기 수동 되돌리기
 
(사용자 2명의 중간 판 46개는 보이지 않습니다)
1번째 줄: 1번째 줄:
var main = function(page) {
  var api_params = {
    action: 'parse',
    format: 'json',
    prop: ['text', 'categorieshtml'],
    disablelimitreport: 1,
    disablestylededuplication: 1,
    utf8: 1,
    formatversion: 'latest',
    redirects: 1
  };
  api_params.page = page;


  var api = new mw.Api();
  api.get(api_params).done(data => {
    var text = data.parse.text; //json에서 데이터 추출.
    var content = text.replaceAll('\n', '').replaceAll('\\', "").replaceAll('href="', 'data-href="') //이스케이프 문자, 링크 제거
    document.querySelector('html').innerHTML = content; //내용 갈아치우기
    document.getElementsByClassName('mw-parser-output')[0].id = "mw-content-text" // 오류 무시
    var links = doc.querySelectorAll('a:not(.external):not(.new)'); //외부링크 구현 문제, 내부 링크 선택
    var linksSize = links.length; //오브젝트? 크기 구하기
    var docTitle; //var docTitle == var page                                                         
    var returnTitle = function() {
      main(docTitle); //본 함수 반복
    }
    for (var i = 0; i < linksSize; i++) {
      var l_link = links[i]
      l_link.style.color = 'blue';
      l_link.onmouseover = function(link) {
        var href = link.target.dataset.href
        var title = href.split("/").pop();
        docTitle = decodeURI(title);
      };
      l_link.onclick = returnTitle;
    }
  });
}
var lightWikiOn = document.createElement('span');
lightWikiOn.className = "dropdown-item"
lightWikiOn.innerText = "라이트 모드"
lightWikiOn.onclick = function() {
  main("사용자")
}
document.querySelector('.dropdown-item[title="사용자 환경 설정"]').before(lightWikiOn)

2024년 2월 6일 (화) 22:18 기준 최신판