利用者:Mizusumashi/Script/EditToolExtention.js
表示
< 利用者:Mizusumashi | Script
お知らせ: 保存した後、ブラウザのキャッシュをクリアしてページを再読み込みする必要があります。
多くの Windows や Linux のブラウザ
- Ctrl を押しながら F5 を押す。
Mac における Safari
Mac における Chrome や Firefox
- ⌘ Cmd と ⇧ Shift を押しながら R を押す。
詳細についてはWikipedia:キャッシュを消すをご覧ください。
// This script is under public domain, and comes with ABSOLUTELY NO WARRANTY.
// You can use/modify/redistribute without any permission.
/*
* Edit Tool Extention
*
* How to use:
* * write "importScript('User:Mizusumashi/Script/EditToolExtention.js');"
* in "User:_ACOUNT_/monobook.js"("_ACOUNT_" is your WIki acount).
* * This script need addOnloadHook()
* in http://upload.wikimedia.org/skins/common/wikibits.js.
*/
var editToolExtentionGroups = [];
editToolExtentionGroups.newGroup = function(name, nameSpases, reg, right)
{
var group = [];
group.name = name;
group.nameSpases = nameSpases;
group.reg = reg;
group.right = right;
group.add = function(name, handler)
{
group.push('<span style="margin-left:0.5ex;white-space:nowrap"><a onclick="' + handler + ';return false" href="#">' + name + '</a></span>');
}
editToolExtentionGroups.push(group);
return group;
}
var ete_TalkPages = ['Talk', 'User Talk', 'Project Talk', 'Image Talk', 'MediaWiki Talk', 'Template Talk', 'Help Talk', 'Category Talk', 'Portal Talk'];
var ete_NameSpaces = [];
ete_NameSpaces['Media'] = -2;
ete_NameSpaces['Special'] = -1;
ete_NameSpaces['Main'] = 0;
ete_NameSpaces['Talk'] = 1;
ete_NameSpaces['User'] = 2;
ete_NameSpaces['User Talk'] = 3;
ete_NameSpaces['Project'] = 4;
ete_NameSpaces['Project Talk'] = 5;
ete_NameSpaces['Image'] = 6;
ete_NameSpaces['Image Talk'] = 7;
ete_NameSpaces['MediaWiki'] = 8;
ete_NameSpaces['MediaWiki Talk'] = 9;
ete_NameSpaces['Template'] = 10;
ete_NameSpaces['Template Talk'] = 11;
ete_NameSpaces['Help'] = 12;
ete_NameSpaces['Help Talk'] = 13;
ete_NameSpaces['Category'] = 14;
ete_NameSpaces['Category Talk'] = 15;
ete_NameSpaces['Portal'] = 100;
ete_NameSpaces['Portal Talk'] = 101;
function ete_InsertTopBottom(top, bottom)
{
var editForm = document.getElementById('editform');
if(! editForm){
return;
}
var value = editForm.wpTextbox1.value;
value = top + '\n' + value;
value = value.replace(/\n*$/, '\n' + bottom + '\n');
editForm.wpTextbox1.value = value;
}
function ete_CloseRequest(pre, post)
{
var editForm = document.getElementById('editform');
if(! editForm){
return;
}
var value = editForm.wpTextbox1.value;
value = value.replace(/{{(確認待ち|WFC).*}}\n/i, '');
value = value.replace(/^[^\n]+/, '$&\n' + pre);
value = value.replace(/\n*$/, '\n' + post + '\n');
editForm.wpTextbox1.value = value;
}
function ete_HasNameSpases(nameSpases)
{
for(var i = 0; i < nameSpases.length; i++)
{
if( wgNamespaceNumber == ete_NameSpaces[nameSpases[i]] ){
return true;
}
}
return false;
}
function ete_HasRight(right)
{
for(var i = 0; i < wgUserGroups.length; i++)
{
if(wgUserGroups[i] == right){
return true;
}
}
return false;
}
function ete_GroupToString(group)
{
if( group.nameSpases && ! ete_HasNameSpases(group.nameSpases) ){
return '';
}
if( group.reg && ! wgPageName.match(group.reg) ){
return '';
}
if( group.right && ! ete_HasRight(group.right) ){
return '';
}
var string = '<br/><b>' + group.name + ':</b>'
for(var i = 0; i < group.length; i++)
{
string += group[i];
}
return string;
}
function ete_AddEditToolExtention()
{
var editTool = document.getElementById('edittools_wikimarkup');
if(! editTool){
return;
}
var string = '';
for(var i = 0; i < editToolExtentionGroups.length; i++)
{
string += ete_GroupToString(editToolExtentionGroups[i]);
}
editTool.innerHTML += string;
}
$(ete_AddEditToolExtention);