미디어위키:Common.js: 두 판 사이의 차이
Resultofunion (토론 | 기여) 편집 요약 없음 |
Resultofunion (토론 | 기여) 편집 요약 없음 |
||
| 44번째 줄: | 44번째 줄: | ||
window.location.href = 'https://churchofgod.wiki/%ED%95%98%EB%82%98%EB%8B%98%EC%9D%98_%EA%B5%90%ED%9A%8C_%EC%A7%80%EC%8B%9D%EC%82%AC%EC%A0%84'; | window.location.href = 'https://churchofgod.wiki/%ED%95%98%EB%82%98%EB%8B%98%EC%9D%98_%EA%B5%90%ED%9A%8C_%EC%A7%80%EC%8B%9D%EC%82%AC%EC%A0%84'; | ||
} | } | ||
if (mw.config.get('wgPageName') == '하나님의_교회_지식사전') { | if (mw.config.get('wgPageName') == '하나님의_교회_지식사전') { | ||
var titles = document.querySelectorAll('.cog-box-title'); | var titles = document.querySelectorAll('.cog-box-title'); | ||
| 129번째 줄: | 130번째 줄: | ||
if (window.Kakao && $kakao) { | if (window.Kakao && $kakao) { | ||
// 사용할 앱의 JavaScript 키를 설정해 주세요. | // 사용할 앱의 JavaScript 키를 설정해 주세요. | ||
Kakao.init(' | Kakao.init('132b053079230ffc0880fd0a8155f444'); | ||
$kakao.children[0].style.display = 'inline'; | $kakao.children[0].style.display = 'inline'; | ||
$kakao.onclick = | $kakao.onclick = sendScrap; // 카카오 Link 공유 API 사용 | ||
window.initKakaoLink = true; | window.initKakaoLink = true; | ||
} else retry = true; | } else retry = true; | ||
| 177번째 줄: | 173번째 줄: | ||
document.execCommand('copy'); | document.execCommand('copy'); | ||
document.body.removeChild(el); | document.body.removeChild(el); | ||
} | |||
function sendScrap() { | |||
// 카카오 Link 공유 API 사용 | |||
Kakao.Link.sendScrap({ | |||
requestUrl: location.href, | |||
templateId: 82911, | |||
templateArgs: { | |||
TITLE: og('title', '하나님의 교회 지식사전'), | |||
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; | |||
} | |||
} | } | ||