「第2回エンペディア大賞」が2月いっぱい開催中です。2024年に作成された記事の中から、お気に入りの記事に投票しましょう!
利用者:BadEditor/test.js
ナビゲーションに移動
検索に移動
注意: 保存後、変更を確認するにはブラウザーのキャッシュを消去する必要がある場合があります。
- Firefox / Safari: Shift を押しながら 再読み込み をクリックするか、Ctrl-F5 または Ctrl-R を押してください (Mac では ⌘-R)
- Google Chrome: Ctrl-Shift-R を押してください (Mac では ⌘-Shift-R)
- Internet Explorer / Microsoft Edge: Ctrl を押しながら 最新の情報に更新 をクリックするか、Ctrl-F5 を押してください
- Opera: Ctrl-F5を押してください
$(document).ready(function() {
var currentUrl = window.location.href;
if (currentUrl.includes("action=history")) {
var containerDiv = document.createElement("div");
var buttonShow = document.createElement("button");
var buttonHide = document.createElement("button");
var contentDiv = document.createElement("div");
containerDiv.style.border = "1px solid #ccc";
containerDiv.style.padding = "10px";
buttonShow.textContent = "移入元情報を表示";
buttonHide.textContent = "閉じる";
buttonShow.style.display = "block";
buttonShow.style.width = "100%";
buttonShow.style.color = "blue";
buttonHide.style.display = "none";
buttonHide.style.backgroundColor = "green";
contentDiv.style.display = "none";
buttonShow.addEventListener("click", function() {
contentDiv.style.display = "block";
buttonShow.style.display = "none";
buttonHide.style.display = "inline";
});
buttonHide.addEventListener("click", function() {
contentDiv.style.display = "none";
buttonShow.style.display = "inline";
buttonHide.style.display = "none";
});
var latestTimestamp = $(".mw-changeslist-date").first().text().trim();
var pageTitle = mw.config.get("wgPageName");
var userlinkSet = new Set();
$(".mw-userlink").each(function() {
userlinkSet.add($(this).text().trim());
});
var userlinkList = Array.from(userlinkSet);
var userList = userlinkList.join("、");
var element = document.querySelector('.mw-pager-navigation-bar');
if (element) {
var noteDiv = document.createElement("div");
noteDiv.textContent = "warning:ページ上に全ての版を表示しているか確認してください";
noteDiv.style.color = "red";
noteDiv.style.fontSize = "15px";
containerDiv.appendChild(noteDiv);
var histTextButton = document.createElement("button");
histTextButton.textContent = "ページの全版を表示する";
histTextButton.style.display = "block";
histTextButton.style.width = "100%";
histTextButton.style.color = "blue";
histTextButton.addEventListener("click", function() {
var rawUrl = "https://ja.wikipedia.org/w/index.php?title=" + pageTitle + "&action=history&limit=5000";
window.location.href = rawUrl;
});
containerDiv.appendChild(histTextButton);
var hr = document.createElement("hr");
containerDiv.appendChild(hr);
}
var button = document.createElement("button");
button.textContent = "この記事をエスケープ転載";
button.style.display = "block";
button.style.width = "100%";
button.style.color = "blue";
button.addEventListener("click", function() {
var url = "https://enpedia.rxy.jp/w/index.php?title=" + pageTitle + "&action=edit&summary=[[jawp:" + pageTitle + "]]の" + latestTimestamp + "の版より全文をエスケープ転載。投稿者: " + userList;
window.open(url, "_blank");
});
containerDiv.appendChild(button);
var rawTextButton = document.createElement("button");
rawTextButton.textContent = "この記事のソースを表示";
rawTextButton.style.display = "block";
rawTextButton.style.width = "100%";
rawTextButton.style.color = "blue";
rawTextButton.addEventListener("click", function() {
var rawUrl = "https://ja.wikipedia.org/w/index.php?title=" + pageTitle + "&action=raw";
window.open(rawUrl, "_blank");
});
containerDiv.appendChild(rawTextButton);
var resultDiv = document.createElement("div");;
resultDiv.innerHTML = "以下、移入元情報を記載する。<br><br>" +
"この記事は [[jawp:" + pageTitle + "]] の" + latestTimestamp + "時点の版から転記された。<br><br>" +
"投稿者: " + userList + "(敬称略)<br><br>" +
"改変点: 無し<br><br>" +
"追記: 無し<br><br>" +
"以上。";
contentDiv.appendChild(resultDiv);
containerDiv.appendChild(buttonShow);
containerDiv.appendChild(buttonHide);
containerDiv.appendChild(contentDiv);
function selectText(element) {
var range = document.createRange();
range.selectNodeContents(element);
var selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
}
document.addEventListener("keydown", function(event) {
if (event.ctrlKey && event.key === "a") {
event.preventDefault();
selectText(contentDiv);
}
});
var subtitleElement = document.querySelector("#mw-content-subtitle");
subtitleElement.appendChild(containerDiv);
}
});
function getFormattedDate(timestamp) {
if (timestamp > 0) {
var latestDate = new Date(timestamp);
var year = latestDate.getUTCFullYear();
var month = ("0" + (latestDate.getUTCMonth() + 1)).slice(-2);
var day = ("0" + latestDate.getUTCDate()).slice(-2);
var hours = ("0" + latestDate.getUTCHours()).slice(-2);
var minutes = ("0" + latestDate.getUTCMinutes()).slice(-2);
var seconds = ("0" + latestDate.getUTCSeconds()).slice(-2);
return year + "年" + month + "月" + day + "日 " + hours + ":" + minutes + ":" + seconds + " (UTC)";
} else {
return "";
}
}