참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다.
- 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R을 입력 (Mac에서는 ⌘-R)
- 구글 크롬: Ctrl-Shift-R키를 입력 (Mac에서는 ⌘-Shift-R)
- 인터넷 익스플로러 / 엣지: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5를 입력.
- 오페라: Ctrl-F5를 입력.
// EditTools 커스텀
mw.loader.load('/index.php?title=사용자:하늘/EditTools.js&action=raw&ctype=text/javascript'); mw.loader.load('/index.php?title=사용자:하늘/EditTools-custom.js&action=raw&ctype=text/javascript');
//mw.loader.load('//commons.wikimedia.org/wiki/MediaWiki:Edittools.js?action=raw&ctype=text/javascript');
// 사용자 문서 상태
mw.loader.load('/index.php?title=사용자:하늘/userinfo.js&action=raw&ctype=text/javascript');
// Imagemap 에디터
if (mw.config.get('wgNamespaceNumber') == 6 && mw.config.get('wgAction') == 'view') {
mw.loader.load('//imagemapedit.toolforge.org/ime.js');
}
//상용구 버튼 추가
mw.loader.load('/index.php?title=사용자:하늘/addbutton.js&action=raw&ctype=text/javascript');
//대용량 이미지 파일 나중에 오픈 스크립트
mw.loader.load('/index.php?title=사용자:하늘/mobile.js&action=raw&ctype=text/javascript');
// 로컬 파일 설명 안 보고 바로 공용으로 넘기기(영어 위키백과, 위키데이터에서 퍼옴)
mw.loader.load('//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-imagelinks.js&action=raw&ctype=text/javascript');
//커스텀 navbar 리버티
mw.loader.load('/index.php?title=사용자:하늘/custom-navbar.js&action=raw&ctype=text/javascript');
//한자 사전 툴
mw.loader.load('/index.php?title=사용자:하늘/hanja-dict-tools.js&action=raw&ctype=text/javascript');
//개선된 문법 강조
//mw.loader.load('/index.php?title=사용자:하늘/HanlsSyntaxhightlighter.js&action=raw&ctype=text/javascript');
/*window.syntaxHighlighterConfig = {
wikilinkColor: '#006eb2', // 내부링크 색상
externalLinkColor: '#31a900', // 외부링크 색상
headingColor: undefined, // 문단 이름 색상
parameterColor: undefined, // 틀 변수 색상
templateColor: undefined, // 틀 코드 색상
tableColor: undefined, // 표 코드 색상
listOrIndentColor: undefined, // 리스트나 들여쓰기(:) 색상
commentColor: undefined, // 주석 색상
tagColor: undefined, // html 태그 색상
sourceTags: undefined, // ["code", "source"] 소스코드를 표시할 html 태그
nowikiTags: undefined, // ["nowiki", "", ""] 위키 문법을 무시하는 html 태그
hrColor: undefined, // <hr>, ---- 색상
boldOrItalicColor: undefined, // 굵게, 글자 기울이기 색상
entityColor: undefined, // 엔티티 색상
signatureColor: undefined, // 서명 색상
timeout: undefined,
};*/
mw.loader.load('/index.php?title=사용자:하늘/addArticleMenuItem.js&action=raw&ctype=text/javascript');
mw.loader.load('/index.php?title=사용자:하늘/addArticleMenuItem-func.js&action=raw&ctype=text/javascript');
//다른 위키로 변경 사항 저장
//mw.loader.load('/index.php?title=사용자:하늘/push.js&action=raw&ctype=text/javascript');
//분류 문서에 편집 링크 추가
document.querySelectorAll('.mw-category a:not(.image, .galleryfilename)').forEach(function (link) {
var catLinksEdit = document.createElement('a');
catLinksEdit.title = link.title + ' 편집하기';
catLinksEdit.href = link.href + '?action=edit';
catLinksEdit.style.paddingLeft = '0.2em';
catLinksEdit.innerHTML = '편집';
// 글자 살짝 작게 표시
catLinksEdit.style.fontSize = '0.9em';
// 스타일링을 위해 별도의 클래스 추가
catLinksEdit.classList.add('fw-edit-link');
link.after(catLinksEdit);
});
//최근 읽은 기록
mw.loader.load('//librewiki.net/index.php?title=사용자:하늘/BreadCrumb.js&action=raw&ctype=text/javascript');
//바로가기 키 추가, 페이지 정보
var pageinfo = document.querySelectorAll('a[href*="action=info"]');
if (pageinfo.length) {
pageinfo[0].accessKey = 'i';
pageinfo[0].title += ' [' + pageinfo[0].accessKey + ']';
}
//리버티-타임리스 스킨 전환
mw.loader.load('/index.php?title=사용자:하늘/switchskin.js&action=raw&ctype=text/javascript');
mw.loader.load('/index.php?title=사용자:하늘/addCopyButtonToCode.js&action=raw&ctype=text/javascript');
//코드 편집기 테마 적용.
mw.hook('codeEditor.configure').add(function () {
const editarea = document.querySelector('.ace_editor');
const aceInstance = ace.edit(editarea);
aceInstance.setOptions({
wrap: false,
theme: './theme/tomorrow_night',
enableLiveAutocompletion: true
});
});
/*** 폰트 설정 ***/
/*var UserAgent = navigator.userAgent;
if (UserAgent.match(/iPhone|iPod|Android|Opera Mini|Opera Mobi|IEMobile/) !== null || UserAgent.match(/LG|SAMSUNG|Samsung/) !== null) {
} else {
console.log('webfont');*/
/*** 폰트 설정 ***/
/*if (window.getComputedStyle(document.querySelector('body')).fontFamily == "Noto Sans KR") {
if (document.querySelectorAll('[lang="ja"], [lang="zh"], [lang="zh-hk"], [lang="zh-tw"]').length) {
var link = document.createElement("link");
link.href = "https://fonts.googleapis.com", link.rel = "preconnect", document.head.append(link);
link = document.createElement("link");
link.href = "https://fonts.gstatic.com", link.rel = "preconnect", link.setAttribute("crossorigin", ""), document.head.append(link);
if (document.querySelectorAll('[lang="ja"]').length) {
link = document.createElement("link")
link.href = "https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@100;300;400;500;700;900&display=swap";
link.rel = "stylesheet";
document.head.append(link)
}
if (document.querySelectorAll('[lang="zh"], [lang="zh-cn"]').length) {
link = document.createElement("link")
link.href = "https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@100;300;400;500;700;900&display=swap";
link.rel = "stylesheet";
document.head.append(link)
}
if (document.querySelectorAll('[lang="zh-hk"]').length) {
link = document.createElement("link")
link.href = "https://fonts.googleapis.com/css2?family=Noto+Serif+HK:wght@100;300;400;500;700;900&display=swap";
link.rel = "stylesheet";
document.head.append(link)
}
if (document.querySelectorAll('[lang="zh-tw"]').length) {
link = document.createElement("link")
link.href = "https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@100;300;400;500;700;900&display=swap";
link.rel = "stylesheet";
document.head.append(link)
}
}
}}*/
function toDark() { setDarkLight('dark'); }
function toLight() { setDarkLight('light'); }
function setAuto() { setDarkLight(null); }
function setDarkLight(option) {
new mw.Api().saveOption('liberty-dark', option).done(function () { location = location });
}
$(function () {
var Button = document.querySelector('.dropdown-divider.view-logout').previousElementSibling.cloneNode();
var ToDarkButton = Button.cloneNode();
ToDarkButton.innerText = '다크모드(강제)';
ToDarkButton.onclick = toDark;
var ToLightButton = Button.cloneNode();
ToLightButton.innerText = '라이트모드(강제)';
ToLightButton.onclick = toLight;
var setAutoButton = Button.cloneNode();
setAutoButton.innerText = '다크모드(자동)';
setAutoButton.onclick = setAuto;
if (mw.user.options.values['liberty-dark'] == undefined) {
$('.dropdown-divider.view-logout').before(ToDarkButton);
$(ToDarkButton).after(ToLightButton);
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
mw.loader.load('/index.php?title=사용자:하늘/liberty-dark.css&action=raw&ctype=text/css', 'text/css'); document.body.classList.add('Liberty-dark');
}
} else if (mw.user.options.values['liberty-dark'] == 'light') {
$('.dropdown-divider.view-logout').before(ToDarkButton);
$(ToDarkButton).after(setAutoButton);
} else if (mw.user.options.values['liberty-dark'] == 'dark') {
$('.dropdown-divider.view-logout').before(setAutoButton);
$(setAutoButton).after(ToLightButton);
mw.loader.load('/index.php?title=사용자:하늘/liberty-dark.css&action=raw&ctype=text/css', 'text/css');
document.body.classList.add('Liberty-dark');
}
});
mw.hook('wikiEditor.toolbarReady').add(function ($textarea) {
$textarea.wikiEditor('addToToolbar', {
section: 'main',
group: 'format',
tools: {
"strikethrough": {
label: '취소선',
type: 'button',
oouiIcon: 'strikethrough',
action: {
type: 'encapsulate',
options: {
pre: "<del>", post: "</del>"
}
}
}
}
});
$textarea.wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
hline: {
label: '수평선',
type: 'button',
oouiIcon: 'subtract',
action: {
type: 'encapsulate',
options: {
pre: '----',
ownline: true
}
}
},
code_nowiki: {
label: '인라인 코드 (nowiki)',
type: 'button',
oouiIcon: 'code',
action: {
type: 'encapsulate',
options: { pre: "<code><nowiki>", post: "</nowiki></code>" }
}
},
code: {
label: '인라인 코드',
type: 'button',
oouiIcon: 'code',
action: {
type: 'encapsulate',
options: { pre: "<code>", post: "</code>" }
}
}
}
});
});
function getRaw(title) {
var raw;
$.ajax({
async: false,
url: location.origin + mw.util.getUrl(title || mw.title, { action: 'raw' }),
success: function (data) { raw = data; }
});
return raw;
}
var mw_parser_output = document.querySelector('.mw-parser-output');
if (mw_parser_output && mw.config.get('wgPageContentModel') == 'wikitext')
console.log(mw_parser_output.innerHTML.match('<!\-\-[^\]*\-\->')[0]);
if (location.search.includes('html2wikitext') && mw.config.get('wgAction') == 'edit') {
mw.hook('ext.CodeMirror').add(function () {
var codemirrorSwitcher = document.querySelector('[rel="codemirror"] a[role="button"]');
if (codemirrorSwitcher.getAttribute('aria-pressed') == 'true') {
codemirrorSwitcher.click();
}
});
document.getElementById('wpTextbox1').addEventListener('paste',
function (event) {
var htmlcode = (event.clipboardData || window.clipboardData).getData('text');
html2wikitext(htmlcode)
});
}
function html2wikitext(htmlcode) {
new mw.Api().postWithEditToken({
"action": "visualeditoredit",
"uselang": "user",
"paction": "serialize",
"page": "사용자:하늘/테스트",//document.title.split(' - ')[0],
"html": htmlcode,
"utf8": 1,
"format": "json",
"formatversion": "latest"
}).done(function (json) {
var generated_wikitext = json.visualeditoredit.content;
document.getElementById('wpTextbox1').value = generated_wikitext;
}).catch(function (data) {
console.log(data);
});
}
/*mw.hook('wikiEditor.toolbarReady').add(function ($textarea) {
$textarea.wikiEditor('addToToolbar', {
section: 'main',
group: 'insert',
tools: {
"markup": {
label: 'html을 위키텍스트로 변환',
type: 'button',
oouiIcon: 'markup',
action: {
type: 'callback',
execute: function (context) {
console.log(context);
html2wikitext(context.$textarea[0].value);
}
}
}
}
});
});*/