User:Kuon.Haku/Twinkle.js
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/**
* +-------------------------------------------------------------------------+
* | === 警告 === |
* | 本工具經過<s>純業餘人士</s>代碼<s>複製拼接</s>復用而成 |
* | 由此造成的一切損失純屬巧合(w |
* | 詳情請見[[User:Kuon.Haku/Twinkle]] |
* +-------------------------------------------------------------------------+
*/
//感谢Jimmy Xu、逆袭的天邪鬼,以及Xiplus的工作,本代码很大程度上基于他们的工作组成。
// 新一代的電子垃圾
// 載入自己修改的Twinkle
(function () {
var VERSION = '7a0b099';
var PREFIX = 'User:Xiplus/Twinkle/';
var rebuildcache = localStorage.A64Twinkle_version !== VERSION;
var tests = [];
var ajax = function (title) {
return $.ajax({
url: 'https://zh.wikipedia.org/w/index.php?title=' + title + '&action=raw&ctype=text/javascript',
dataType: 'text',
});
};
var load = function (p) {
var done = function (data) {
if (rebuildcache || !localStorage['A64Twinkle_' + p.name]) {
localStorage['A64Twinkle_' + p.name] = data;
}
};
if (localStorage['A64Twinkle_' + p.name] && !rebuildcache) {
return $.Deferred().resolve(localStorage['A64Twinkle_' + p.name]);
} else {
if (p.test) {
return ajax(p.name).done(done);
} else {
return ajax('MediaWiki:Gadget-' + p.name).done(done);
}
}
};
var message = function (text) {
console.log('[A64Twinkle]', text);
// $('#simpleSearch input[type="search"]').attr('placeHolder', text);
};
tests.push({name: 'User:Xiplus/Twinkle/morebits.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/twinkle.js', test: true});
tests.push({name: 'User:Kuon.Haku/Twinkle/modules/twinklearv.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinklewarn.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/friendlyshared.js', test: true});
tests.push({name: 'User:Kuon.Haku/Twinkle/modules/friendlytag.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/friendlytalkback.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinklebatchdelete.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinklebatchundelete.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinkleblock.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinkleclose.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinkleconfig.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinklecopyvio.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinkledelimages.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinklediff.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinklefluff.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinkleimage.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinkleprotect.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinklespeedy.js', test: true});
tests.push({name: 'User:Xiplus/Twinkle/modules/twinkleunlink.js', test: true});
tests.push({name: 'User:Kuon.Haku/Twinkle/modules/twinklexfd.js', test: true});
mw.loader.using(['mediawiki.user', 'mediawiki.util', 'mediawiki.util', 'mediawiki.Title', 'jquery.ui', 'jquery.tipsy']).done(function () {
mw.loader.load('https://zh.wikipedia.org/w/index.php?title=User:Kuon.Haku/Twinkle/morebits.css&action=raw&ctype=text/css', 'text/css');
var i=0;
var finished = 0;
var code = [];
// all
message('Loading A64TW...');
var promises = [];
var done = function (x) {
return function (data) {
finished++;
//message('Loading A64TW... (' + finished + '/' + tests.length + ')');
code[x] = data;
};
};
for (i=0; i<tests.length; i++) {
promises.push(load(tests[i]).done(done(i)));
}
$.when.apply($, promises).done(function () {
localStorage.A64Twinkle_version = VERSION;
eval(code.join('\n;\n'));
message('Twinkle Done');
if($('#twinkle-config-titlebar').length) {
$('#twinkle-config-titlebar').append("--版本::-)"+localStorage.A64Twinkle_version)
}
});
});
})();