// ==UserScript==
// @name Address List BGP
// @namespace https://laksa19.github.io/addrlistbgp
// @updateURL https://raw.githubusercontent.com/laksa19/addrlistbgp/main/addrlistbgp.user.js
// @downloadURL https://raw.githubusercontent.com/laksa19/addrlistbgp/main/addrlistbgp.user.js
// @version 0.8
// @description Get Adress List from BGP
// @author Laksamadi Guko
// @match https://bgp.he.net/search*
// @match https://bgp.he.net/AS*
// @grant none
// @require http://code.jquery.com/jquery-3.4.1.min.js
// ==/UserScript==
(function() {
'use strict';
$("#content").prepend(`
`
);
$("#header_search").append("Get Address List Script");
$("#getscript").click(function(){
getIP();
})
$("#cpscript").click(function(){
copyTable(document.getElementById("tblresult"));
})
$("#close").click(function(){;
$("#result").hide()
$("#tblresult").html("");
})
function getIP(){
$("#tblresult").html("");
$("#tblresult").append("| /ip firewall address-list |
")
var tr = $('table tr').filter(function() {
return $(this).find("td");
});
tr.each(function() {
var list ="";
var ip = ($(this).find('a').html());
if(location.href.split("/")[3].substr(0,2) == "AS"){
list = $('#header').find('a')[1].innerHTML.split(location.href.split("/")[3].split('#')[0])[1];
}else{
list = $('#header').find('h1')[0].innerHTML.split('"')[1].split('"')[0];
}
if(ip && ip.split(".").length == 4){
$("#tblresult").append(`| add list="`+list+`" address=`+ip+` |
`);
}
});
$("#tblresult").append(" |
");
$("#result").show();
}
function copyTable(el) {
var body = document.body, range, sel;
if (document.createRange && window.getSelection) {
range = document.createRange();
sel = window.getSelection();
sel.removeAllRanges();
try {
range.selectNodeContents(el);
sel.addRange(range);
} catch (e) {
range.selectNode(el);
sel.addRange(range);
}
} else if (body.createTextRange) {
range = body.createTextRange();
range.moveToElementText(el);
range.select();
}
document.execCommand("copy");
}
})();