javascript - 用于提取 URL 特征的 Chrome 扩展内容脚本
问题描述
这只是构建 Chrome 扩展程序以检测网络钓鱼 URL 的代码片段。下面的代码用于提取 URL 特征。我不明白的是function predict(data,weight)
. 重量中的数字是什么?例如: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);
还有许多其他 URL 功能功能代码,但这里我只包括一个示例,即检查长 URL。
解决方案
推荐阅读
- javascript - Ext.JS:JavaScript 中的参考模型
- c++ - 将派生实现标记为 noexcept 而接口不是的副作用是什么
- r - R使用Group by和Mutate创建自定义函数
- c# - 如何使用grpc通过服务器在客户端之间发送消息?
- asp.net - 从 select2:select 事件调用 asp.net webform 回发
- c - 无符号减法,值仍算小于 0
- java - 不推荐使用(上下文)方法
- node.js - 查找字符串并删除行 - Node.JS
- mysql - 循环运行多个 Sql 命令
- react-select - 如何仅使用 react-select onChange 事件和 value 道具中的值?