This is only a snippet of code for building Chrome extension to detect phishing URL. The code below is to extract the URL features. What I do not understand is the purpose of function predict(data,weight). What are the numbers in weight for ? Eg: weight = [3.33346292e-01, ...]
var testdata;
var prediction;
function predict(data,weight){
var f = 0;
weight = [3.33346292e-01,-1.11200396e-01,-7.77821806e-01,1.11058590e-01,3.89430647e-01,1.99992062e+00,4.44366975e-01,-2.77951957e-01,-6.00531647e-05,3.33200243e-01,2.66644002e+00,6.66735991e-01,5.55496098e-01,5.57022408e-02,2.22225591e-01,-1.66678858e-01];
for(var j=0;j<data.length;j++) {
f += data[j] * weight[j];
}
return f > 0 ? 1 : -1;
}
function isLongURL(){
var url = window.location.href;
if(url.length<54){
console.log("NP");
return -1;
}
else if(url.length>=54 && url.length<=75){
console.log("Maybe");
return 0;
}
else{
console.log("P");
return 1;
}
}
testdata = [isLongURL(),isTinyURL(),isAlphaNumericURL(),isRedirectingURL(),isHypenURL()];
prediction = predict(testdata);
chrome.extension.sendRequest(prediction);
There are many other URL features function code but here I only included one example which is the checking for Long URL.