Created
April 16, 2020 07:42
-
-
Save iamriajul/0c4718e48b0df69b831b6f1c40d254f1 to your computer and use it in GitHub Desktop.
Block Device Support for D-Link Router from Active Clients
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Block Device: Active Client | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match http://192.168.100.1/dhcptbl.htm | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
window.ipPrefix = '192.168.100.'; | |
String.prototype.replaceAll = function(search, replacement) { | |
var target = this; | |
return target.split(search).join(replacement); | |
}; | |
window.setCookie = function (cname, cvalue, exdays) { | |
var d = new Date(); | |
d.setTime(d.getTime() + (exdays*24*60*60*1000)); | |
var expires = "expires="+ d.toUTCString(); | |
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; | |
} | |
window.getCookie = function (cname) { | |
var name = cname + "="; | |
var decodedCookie = decodeURIComponent(document.cookie); | |
var ca = decodedCookie.split(';'); | |
for(var i = 0; i <ca.length; i++) { | |
var c = ca[i]; | |
while (c.charAt(0) == ' ') { | |
c = c.substring(1); | |
} | |
if (c.indexOf(name) == 0) { | |
return c.substring(name.length, c.length); | |
} | |
} | |
return ""; | |
} | |
var table = document.getElementsByClassName('formlisting')[1]; | |
if (table == undefined) { | |
table = document.getElementsByClassName('formlisting')[0]; | |
} | |
var trs = table.getElementsByTagName('tr'); | |
trs[0].innerHTML = trs[0].innerHTML + '<td class="form_label_col">Action</td>'; | |
for (let i = 1; i < trs.length; i++) { | |
var tr = trs[i]; | |
var mac = tr.getElementsByTagName('td')[2].getElementsByTagName('b')[0].getElementsByTagName('span')[0]; | |
if (mac == undefined) { | |
mac = tr.getElementsByTagName('td')[2].getElementsByTagName('b')[0]; | |
} | |
mac = mac.innerText; | |
tr.innerHTML = tr.innerHTML + '<td><button onclick="window.blockDevice(\'' + mac + '\');return false;">Block</button></td>'; | |
} | |
window.blockDevice = function (mac) { | |
window.setCookie('deviceToBlock', mac, 30); | |
location.pathname = 'lan.htm'; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment