User:Kwj2772/shade.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at User:Kwj2772/shade. |
- Report page listing warnings and errors.
/* Hide offensive but used images when you don't want to see images on Commons
* Developed by [[User:Kwj2772]]
*/
if (typeof (cat_string_to_hide) == 'undefined')
var cat_string_to_hide = ['BDSM', 'Sex', 'Orgasm']; // without Category: prefix
if (typeof (filter_using_extlinks) == 'undefined')
var extlinks_addresses = []; // Hide image if document contain specific links. Please specify link addresses here
function image_filter() {
for (var i = 0; i < cat_string_to_hide.length; i++) {
for (var j = 0; j < wgCategories.length; j++) {
if (wgCategories[j].indexOf(cat_string_to_hide[i]) != -1) {
var tohide = true; // End cat_filter. Hidden on category gallery (Not on NS-0) and file page.
}
}
}
var a = document.getElementsByTagName('a');
for (var k = 0; k < a.length; k++) {
for (var l = 0; l < extlinks_addresses; l++) {
if (a[k].getAttribute('src').indexOf(extlinks_addresses[l]) != -1) var tohide = true;
}
}
var url_exception_param = getParamValue('unshade');
if (url_exception_param == '1') var tohide = false;
if (tohide == true) image_shade();
}
function image_shade() {
var shade_message_i18n_sing = {
'en': 'The file is hidden because it is considered to be an offensive material. If you want to see the image, click <a href=\"'+ wgServer + '/w/index.php?unshade=1&title=' + encodeURIComponent(mw.config.get('wgPageName')) + '\">here</a> or disable the script.',
'ko': '이 파일은 혐오감을 줄 수 있는 파일이라 판단되어 숨겨졌습니다. 그림을 보기를 원하신다면 <a href=\"'+ wgServer + '/w/index.php?unshade=1&title=' + encodeURIComponent(mw.config.get('wgPageName')) + '\">이곳</a>을 클릭하거나 이 스크립트를 끄십시오.'
};
var shade_message_i18n_plural = {
'en': 'The files are hidden because they are considered to be offensive materials. If you want to see the images, click <a href=\"'+ wgServer + '/w/index.php?unshade=1&title=' + encodeURIComponent(mw.config.get('wgPageName')) + '\">here</a> or disable the script.',
'ko': '여기 있는 파일은 혐오감을 줄 수 있는 파일이라 판단되어 숨겨졌습니다. 그림을 보기를 원하신다면 <a href=\"'+ wgServer + '/w/index.php?unshade=1&title=' + encodeURIComponent(mw.config.get('wgPageName')) + '\">이곳</a>을 클릭하거나 이 스크립트를 끄십시오.'
};
var shade_message_sing = shade_message_i18n_sing[wgUserLanguage] || shade_message_i18n_sing['en'];
var shade_message_plural = shade_message_i18n_plural[wgUserLanguage] || shade_message_i18n_plural['en'];
appendCSS('table, #file { display: none; }');
var body = document.getElementById('bodyContent');
if (wgNamespaceNumber == 6)
body.innerHTML = shade_message_sing;
if (wgNamespaceNumber == 14 )
body.innerHTML = shade_message_plural;
}
addOnloadHook(image_filter);