Участник:W2/vector.js
Замечание: Возможно, после публикации вам придётся очистить кэш своего браузера, чтобы увидеть изменения.
- Firefox / Safari: Удерживая клавишу Shift, нажмите на панели инструментов Обновить либо нажмите Ctrl+F5 или Ctrl+R (⌘+R на Mac)
- Google Chrome: Нажмите Ctrl+Shift+R (⌘+Shift+R на Mac)
- Internet Explorer / Edge: Удерживая Ctrl, нажмите Обновить либо нажмите Ctrl+F5
- Opera: Нажмите Ctrl+F5.
mw.loader.load( "//en.wikipedia.org/w/index.php?title=User:PleaseStand/userinfo.js&action=raw&ctype=text/javascript" );
mw.loader.load('//commons.wikimedia.org/w/index.php?title=MediaWiki:Search-results-new-tab.js&action=raw&ctype=text/javascript');
mw.loader.load( "//en.wikipedia.org/w/index.php?title=User:Numbermaniac/goToTop.js&action=raw&ctype=text/javascript" );
mw.loader.load( "//en.wikipedia.org/w/index.php?title=User:Ucucha/duplinks.js&action=raw&ctype=text/javascript" );
// en.wikipedia.org/w/index.php?title=User:Writ Keeper/Scripts/googleTitle.js
$(googleTitle);
function googleTitle()
{
if(wgCanonicalNamespace == "")
{
var subjectName;
if(wgPageName.charAt(wgPageName.length - 1) == ")")
{
subjectName = wgPageName.substring(0, wgPageName.lastIndexOf("(") - 1);
}
else
{
subjectName = wgPageName;
}
var searchNode = document.createElement("a");
searchNode.href = "http://www.google.com/search?q=" + subjectName.replace(/_/g, " ") + "";
searchNode.target = "_blank";
searchNode.innerHTML = "<span style='font-size:x-small;'> Google</span>";
document.getElementById("firstHeading").appendChild(searchNode);
}
}
$(yandexTitle);
function yandexTitle()
{
if(wgCanonicalNamespace == "")
{
var subjectName;
if(wgPageName.charAt(wgPageName.length - 1) == ")")
{
subjectName = wgPageName.substring(0, wgPageName.lastIndexOf("(") - 1);
}
else
{
subjectName = wgPageName;
}
var searchNode2 = document.createElement("a");
searchNode2.href = "http://www.yandex.ru//yandsearch?text=" + subjectName.replace(/_/g, " ") + "";
searchNode2.target = "_blank";
searchNode2.innerHTML = "<span style='font-size:x-small;'> Yandex</span>";
document.getElementById("firstHeading").appendChild(searchNode2);
}
}
$(yahooTitle);
function yahooTitle()
{
if(wgCanonicalNamespace == "")
{
var subjectName;
if(wgPageName.charAt(wgPageName.length - 1) == ")")
{
subjectName = wgPageName.substring(0, wgPageName.lastIndexOf("(") - 1);
}
else
{
subjectName = wgPageName;
}
var searchNode3 = document.createElement("a");
searchNode3.href = "http://search.yahoo.com/search?p=" + subjectName.replace(/_/g, " ") + "";
searchNode3.target = "_blank";
searchNode3.innerHTML = "<span style='font-size:x-small;'> Yahoo</span>";
document.getElementById("firstHeading").appendChild(searchNode3);
}
}
$(askTitle);
function askTitle()
{
if(wgCanonicalNamespace == "")
{
var subjectName;
if(wgPageName.charAt(wgPageName.length - 1) == ")")
{
subjectName = wgPageName.substring(0, wgPageName.lastIndexOf("(") - 1);
}
else
{
subjectName = wgPageName;
}
var searchNode4 = document.createElement("a");
searchNode4.href = "http://ask.com/web?q=" + subjectName.replace(/_/g, " ") + "";
searchNode4.target = "_blank";
searchNode4.innerHTML = "<span style='font-size:x-small;'> Ask</span>";
document.getElementById("firstHeading").appendChild(searchNode4);
}
}
// list of "todo" pages and button legends for PageCollector
var pagesToCollect = [
{page: 'Участник:W2/Todo', caption: 'Todo'}
];
mw.loader.load( "//en.wikipedia.org/w/index.php?title=User:קיפודנחש/pageCollector.js&action=raw&ctype=text/javascript" );
// importScript('User:The Evil IP address/hdedit.js'); to Russian;
/**
* Allows for one click modification of section headings when viewing a page
* add importScript('User:The Evil IP address/hdedit.js'); to your .js file to use it
* TODO: Multiple sections can be opened for editing, but after saving one, the data of all others is lost due to reloading
*/
window.hdedit = {
onclick: function ($e) {
hdedit.anchor = $e.attr('id');
hdedit.pagename = mw.config.get('wgPageName');
hdedit.api = mw.util.wikiScript('api');
hdedit.$e = $e;
$.getJSON(hdedit.api, {
action: 'parse',
page: this.pagename,
prop: 'sections',
format: 'json'
}, function (data) {
$.each(data.parse.sections, function (i, v) {
if (v.anchor == hdedit.anchor) {
hdedit.index = v.index;
return false;
}
});
$.getJSON(hdedit.api, {
action: 'parse',
page: hdedit.pagename,
section: hdedit.index,
prop: 'wikitext',
format: 'json'
}, function (obj) {
hdedit.wikitext = obj.parse.wikitext['*'];
hdedit.section_wikitext = hdedit.wikitext.replace(/^(=+)\s*(.+?)\s*\1[\s\S]+$/, '$2');
var form = $('<form>').css('display', 'inline').submit(hdedit.save);
var input = $('<input>').attr('id', 'hdedit_input').val(hdedit.section_wikitext);
var button1 = $('<button>').attr('id', 'hdedit_submit').attr('type', 'submit').text('Save');
var button2 = $('<button>').attr('type', 'button').attr('id', 'hdedit_cancel').text('Cancel').click(hdedit.cancel);
$(form).append(input).append(button1).append(button2);
$e.after(form);
$e.hide();
}
);
}
);
},
save: function () {
hdedit.newheading = $(this).parent().find('input').attr('value');
if (hdedit.newheading == hdedit.section_wikitext) return false;
$.getJSON(hdedit.api, {
action: 'query',
prop: 'info',
intoken: 'edit',
titles: hdedit.pagename,
format: 'json',
indexpageids: true
}, function (re) {
$('#hdedit_input, #hdedit_submit, #hdedit_cancel').attr('disabled', 'disabled');
$.post(hdedit.api, {
action: 'edit',
format: 'json',
title: hdedit.pagename,
section: hdedit.index,
minor: true,
summary: 'Коррекция заголовка: ' + hdedit.section_wikitext + ' → ' + hdedit.newheading + ' с помощью [[:en:User:The Evil IP address/hdedit|Hdedit]]',
text: hdedit.wikitext.replace(/^(=+)(\s*).+?(\s*)\1(\s*)$/m, '$1$2' + hdedit.newheading + '$3$1$4'),
token: re.query.pages[re.query.pageids[0]].edittoken
}, function (data) {
if (data.edit.result == 'Success') {
window.location.reload();
}
else if (data.error) {
alert('API returned error code ' + data.error.code + ': ' + data.error.info + '\nPlease edit the section heading manually.');
}
else {
alert('Unknown API error. Please edit the section heading manually.');
}
});
});
return false;
},
cancel: function () {
hdedit.$e.show();
$(this).parent().remove();
}
};
if (mw.config.get('wgNamespaceNumber') >= 0 && mw.config.get('wgAction') == 'view') {
$('h1 span.mw-headline, h2 span.mw-headline, h3 span.mw-headline, h4 span.mw-headline, h5 span.mw-headline, h6 span.mw-headline').click(function () {hdedit.onclick($(this));});
}