مستخدم:وهراني/Twinkle-on.js
يمكن توفير توثيق لسكربت المستخدم هذا في الصفحة : مستخدم:وهراني/Twinkle-on. |
ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات ( ).
// 載入自己修改的Twinkle
(function () {
var groups = mw.config.get('wgUserGroups');
var VERSION = 'c23e288';
var PREFIX = 'MediaWiki:Gadget-';
var rebuildcache = localStorage.fakeTwinkle_version !== VERSION;
var tests = [];
var ajax = function (title) {
return $.ajax({
url: mw.config.get('wgScript') + '?title=' + title + '&action=raw&ctype=text/javascript',
dataType: 'text',
});
};
var load = function (p) {
var done = function (data) {
if (rebuildcache || !localStorage['fakeTwinkle_' + p.name]) {
localStorage['fakeTwinkle_' + p.name] = data;
}
};
if (localStorage['fakeTwinkle_' + p.name] && !rebuildcache) {
return $.Deferred().resolve(localStorage['fakeTwinkle_' + p.name]);
} else {
if (p.test) {
return ajax(PREFIX + p.name).done(done);
} else {
return ajax('MediaWiki:Gadget-' + p.name).done(done);
}
}
};
var message = function (text) {
console.log('[FakeTwinkle]', text);
// $('#simpleSearch input[type="search"]').attr('placeHolder', text);
};
//tests.push({name: 'morebits(old).js', test: true});
tests.push({name: 'Twinkle(old).js', test: true});
tests.push({name: 'twinklearv.js', test: true});
tests.push({name: 'twinklewarn.js', test: true});
tests.push({name: 'friendlyshared.js', test: true});
tests.push({name: 'friendlytag.js', test: true});
tests.push({name: 'friendlytalkback.js', test: true});
tests.push({name: 'twinklebatchdelete.js', test: true});
tests.push({name: 'twinklebatchundelete.js', test: true});
tests.push({name: 'twinkleblock.js', test: true});
tests.push({name: 'twinkleclose.js', test: true});
tests.push({name: 'twinkleconfig.js', test: true});
tests.push({name: 'twinklecopyvio.js', test: true});
tests.push({name: 'twinkledelimages.js', test: true});
tests.push({name: 'twinklediff.js', test: true});
tests.push({name: 'twinklefluff.js', test: true});
//tests.push({name: 'twinkleimage.js', test: true});
tests.push({name: 'twinkleprotect.js', test: true});
tests.push({name: 'twinklespeedy.js', test: true});
tests.push({name: 'twinkleunlink.js', test: true});
tests.push({name: 'twinklexfd.js', test: true});
mw.loader.using(['morebits','select2' , 'mediawiki.api','mediawiki.language'
//, 'jquery.ui', 'jquery.tipsy'
]).done(function () {
//importStylesheet('MediaWiki:Gadget-morebits.css');
//importScript('MediaWiki:Gadget-select2.min.js');
//importStylesheet('MediaWiki:Gadget-select2.min.css');
importStylesheet('MediaWiki:Gadget-Twinkle.css');
importStylesheet('MediaWiki:Gadget-Twinkle-pagestyles.css');
var i=0;
var finished = 0;
var code = [];
// all
message('Loading FakeTW...');
var promises = [];
var done = function (x) {
return function (data) {
finished++;
//message('Loading FakeTW... (' + 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.fakeTwinkle_version = VERSION;
eval(code.join('\n;\n'));
message('Twinkle Done');
});
});
})();