Χρήστης:Geraki/dynip.js
Εμφάνιση
Μετά την αποθήκευση πρέπει να καθαρίσετε την κρυφή μνήμη (cache) του browser σας για να δείτε τις αλλαγές: Σε Chrome, Firefox, Safari, Internet Explorer και Edge: Κρατήστε πατημένο το ⇧ Shift και κάντε κλικ στο κουμπί Ανανέωση στην μπάρα εργαλείων.
// Author: [[pl:User:Beau]]
var di$message = 'Αυτός ο χρήστης χρησιμοποιεί μια δυναμική διεύθυνση IP <span style="white-space:nowrap">($1)</span>';
var di$blockExpiry = '2 hours';
var di$list = new Array(
1040318463, 65535, 'Forthnet', // 62.1.0.0/16
1295122431, 65535, 'Forthnet', // 77.49.0.0/16
1332215807, 65535, 'Forthnet', // 79.103.0.0/16
-1140523009, 65535, 'Forthnet', // 188.4.0.0/16
-1050869761, 65535, 'Forthnet', // 193.92.0.0/16 +st
-1025769473, 65535, 'Forthnet', // 194.219.0.0/16 +st
-1018494977, 8191, 'Forthnet', // 195.74.224.0/19
-734601217, 8191, 'Forthnet', // 212.54.192.0/19
-721715201, 32767, 'Forthnet', // 212.251.0.0/17
1334050815, 262143, 'Otenet', // 79.128.0.0/14
1047003135, 65535, 'Otenet', // 62.103.0.0/16
1407975423, 65535, 'Otenet', // 83.235.0.0 /16
1507000319, 65535, 'Hellas On Line', // 89.210.0.0/16
1535836159, 32767, 'Hellas On Line', // 91.138.128.0/17
1042743295, 65535, 'Hellas On Line', // 62.38.0.0/16
-1038163969, 8191, 'Hellas On Line', // 194.30.192.0/19
-1038155777, 8191, 'Hellas On Line', // 194.30.224.0/19
1336410111, 131071, 'Hellas On Line', // 79.166.0.0/15
-1017020417, 32767, 'Hellas On Line' // 195.97.0.0/17
);
function di$ip2long(ip)
{
var ip_array = ip.split('.');
return Number(ip_array[3]) + 256 * (Number(ip_array[2]) + 256 * (Number(ip_array[1]) + 256 * ip_array[0]));
}
function di$isDynamicIP(ip)
{
var ip_long = di$ip2long(ip);
for (var i = 0; i < di$list.length; i += 3) {
if (di$list[i] == (ip_long | di$list[i+1]))
return di$list[i+2];
}
return false;
}
function di$createFmbox(text)
{
var table = document.createElement('table');
table.className = 'fmbox fmbox-content';
table.style.marginTop = '5px';
table.style.marginBottom = '5px';
var tr = document.createElement('tr');
var td_image = document.createElement('td');
td_image.className = 'mbox-image';
var td_text = document.createElement('td');
td_text.className = 'mbox-text';
var image = document.createElement('img');
image.src = 'http://upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Emblem-important.svg/40px-Emblem-important.svg.png';
image.height = 40;
image.width = 40;
td_image.appendChild(image);
tr.appendChild(td_image);
td_text.innerHTML = text;
tr.appendChild(td_text);
table.appendChild(tr);
return table;
}
$(function()
{
var address;
// jeżeli to jest strona 'Blokuj'
if (wgCanonicalSpecialPageName == "Blockip") {
var blockip = document.getElementById('blockip');
if (! blockip )
return;
address = blockip.wpBlockAddress.value;
}
else if (wgCanonicalNamespace == "User_talk") {
address = wgTitle;
}
else if (wgCanonicalSpecialPageName == "Contributions") {
var contentSub = document.getElementById('contentSub');
if (!contentSub)
return;
var links = contentSub.getElementsByTagName('a');
if (links.length) {
var ip = links[0].href.match(/:(\d+\.\d+\.\d+\.\d+)(?:$|&)/);
if (ip)
address = ip[1];
}
}
if (!address)
return;
if (!address.match(/^\d+\.\d+\.\d+\.\d+$/))
return;
var state = di$isDynamicIP(address);
if (state) {
var box = di$createFmbox(di$message.replace('$1', state));
var bodyContent = document.getElementById('bodyContent');
var jumptonav = document.getElementById('mw-content-text');
bodyContent.insertBefore(box, jumptonav);
var wpBlockExpiry = document.getElementById('wpBlockExpiry');
if (wpBlockExpiry) {
wpBlockExpiry.value = di$blockExpiry;
wpBlockExpiry.onchange();
}
}
});