참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다.
- 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R을 입력 (Mac에서는 ⌘-R)
- 구글 크롬: Ctrl-Shift-R키를 입력 (Mac에서는 ⌘-Shift-R)
- 인터넷 익스플로러 / 엣지: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5를 입력.
- 오페라: Ctrl-F5를 입력.
var doc = document;
var main = function(page) {
var api_params = {
action: 'parse',
page: page,
format: 'json',
prop: ['text', 'categorieshtml'],
disablelimitreport: 1,
disablestylededuplication: 1,
utf8: 1,
formatversion: 'latest',
redirects: 1
};
var api = new mw.Api();
api.get(api_params).done(data => {
var content = data.parse.text.replaceAll('\n', '').replaceAll('\\', "").replaceAll('href="', 'data-href="'); //이스케이프 문자, 링크 제거
doc.querySelector('html').innerHTML = content; //내용 갈아치우기
doc.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 isinternalLink = true;
// var toLink = function() {};
var toLink = function(link) {
var href = link.target.dataset.href;
if (href.includes('index.php') === true) {
console.log(href);
window.open(href);
} else {
console.log(docTitle);
docTitle = decodeURI(href.split("/").pop());
main(docTitle); //본 함수 반복
isinternalLink = false;
}
}; //내부 링크
//var getLink = function(link) {
// docTitle = decodeURI(link.target.dataset.href.split("/").pop());
//}; //편집 버튼, 문단 링크
var start = new Date().getTime();
for (var i = 0; i < linksSize; i++) {
var l_link = links[i];
l_link.style.cssText = "color: blue; cursor: pointer;";
//l_link.onmouseover = getTitle;
l_link.onclick = toLink;
}
var end = new Date().getTime();
console.log((end - start) + " : time");
});
};
var lightWikiOn = document.createElement('span');
lightWikiOn.className = "dropdown-item";
lightWikiOn.innerText = "라이트 모드";
lightWikiOn.onclick = function() {
alert(window.location.href.split("/wiki/").pop());
// main(window.href);
};
doc.querySelector('.dropdown-item[title="사용자 환경 설정"]').before(lightWikiOn);