편집 요약 없음 |
편집 요약 없음 |
||
6번째 줄: | 6번째 줄: | ||
if (response.ok) return response.json(); | if (response.ok) return response.json(); | ||
throw new Error('Network response was not ok.'); | throw new Error('Network response was not ok.'); | ||
console.log(response); | |||
// .match(new RegExp("<title.*?>(.*?)</title>")); | |||
document.querySelector(".mw-wikiEditor-InsertLink-LinkTextField .oo-ui-inputWidget-input").value = res | |||
}) | }) | ||
.then(data => console.log(data.contents)); | .then(data => console.log(data.contents)); |
2023년 12월 15일 (금) 21:14 기준 최신판
let Inputfield = document.querySelector(".mw-wikiEditor-InsertLink-TitleInputField .oo-ui-inputWidget-input");
function getTitle () {
fetch(`https://api.allorigins.win/get?url=${encodeURIComponent(Inputfield.value)}`)
.then(response => {
if (response.ok) return response.json();
throw new Error('Network response was not ok.');
console.log(response);
// .match(new RegExp("<title.*?>(.*?)</title>"));
document.querySelector(".mw-wikiEditor-InsertLink-LinkTextField .oo-ui-inputWidget-input").value = res
})
.then(data => console.log(data.contents));
}
var btnElement = new OO.ui.ButtonWidget({ data: 1, label: "자동 입력", title: "" });
btnElement.on('click', getTitle);
$(".mw-wikiEditor-InsertLink-LinkTextField .oo-ui-fieldLayout-field").append("<div> </div>");
$(".mw-wikiEditor-InsertLink-LinkTextField .oo-ui-fieldLayout-field").append(btnElement.$element);