「MediaWiki:Common.js」の版間の差分
ナビゲーションに移動
検索に移動
Sufee Admin (トーク | 投稿記録) 編集の要約なし |
Sufee Admin (トーク | 投稿記録) 編集の要約なし |
||
91行目: | 91行目: | ||
const div = document.createElement("div"); | const div = document.createElement("div"); | ||
div.className = "promotion"; | div.className = "promotion"; | ||
div.innerHTML = '<a href="https://twitter.com/real_sufee?ref_src=twsrc%5Etfw" class="twitter-follow-button" data-show-screen-name="false" data-lang="ja" data-show-count="false"><i></i> | div.innerHTML = '<a href="https://twitter.com/real_sufee?ref_src=twsrc%5Etfw" class="twitter-follow-button" data-show-screen-name="false" data-lang="ja" data-show-count="false"> <i></i> </a><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>' | ||
panel.appendChild(div); | panel.appendChild(div); | ||
} | } |
2022年1月27日 (木) 21:15時点における最新版
/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */
mw.loader.using(['mediawiki.util'], function (){
function pageConfig(){
function addInitialize(){
const body = document.getElementsByTagName("body")[0];
try{
const bodyScript_data = {
"id":"myScript-mw-script",
"element":"div",
"display":"none",
};
const bodyScript = document.createElement(bodyScript_data.element);
bodyScript.id = bodyScript_data.id;
bodyScript.style.display = bodyScript_data.display;
body.appendChild(bodyScript);
}catch(err){
console.log(err);
}
try{
const bodyCSS_data = {
"id":"myScript-mw-css",
"element":"div",
"display":"none",
};
const bodyCss = document.createElement(bodyCSS_data.element);
bodyCss.id = bodyCSS_data.id;
bodyCss.style.display = bodyCSS_data.display;
body.appendChild(bodyCss);
}catch(err){
console.log(err);
}
}
function getList(doc){
try{
const item = [];
if(doc != null){
const temp = doc.getElementsByTagName("li");
if(temp != null){
for(var i = 0 , l = temp.length;i < l;i++){
item[i] = temp[i];
}
}
}
if(item.length >= 1){
return item;
}
return null;
}catch(err){
console.log(err);
return null;
}
}
addInitialize();
const addScriptFile = getList(document.getElementById("Script-files"));
const addCSSFile = getList(document.getElementById("CSS-files"));
if(addScriptFile != null){
const mw_script = document.getElementById("myScript-mw-script");
for(var i = 0,l = addScriptFile.length;i < l; i++){
var scriptElement = document.createElement("script");
if(addScriptFile[i].type == "file"){
scriptElement.src = addScriptFile[i].innerText;
}else if(addScriptFile[i].type == "inner"){
scriptElement.innerHTML = addScriptFile[i].innerText;
}else{
scriptElement.src = addScriptFile[i].innerText;
}
mw_script.appendChild(scriptElement);
}
}
if(addCSSFile != null){
const mw_css = document.getElementById("myScript-mw-css");
for(var i = 0,l = addCSSFile.length;i < l; i++){
var css = document.createElement("link");
if(addCSSFile[i].type == "file"){
css.href = addCSSFile[i].innerText;
css.rel = "stylesheet";
}else if(addCSSFile[i].type == "inner"){
css.innerHTML = addCSSFile[i].innerText;
}else{
css.href = addCSSFile[i].innerText;
css.rel = "stylesheet";
}
mw_css.appendChild(css);
}
}
}
function left_action(){
const panel = document.getElementById("mw-panel");
const div = document.createElement("div");
div.className = "promotion";
div.innerHTML = '<a href="https://twitter.com/real_sufee?ref_src=twsrc%5Etfw" class="twitter-follow-button" data-show-screen-name="false" data-lang="ja" data-show-count="false"> <i></i> </a><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>'
panel.appendChild(div);
}
left_action();
pageConfig();
});