Javascript JS脚本上未定义的变量数组
想知道是否有人能帮上忙 我有一个脚本,它拒绝在我的浏览器的最新版本上工作(在旧版本中工作),并希望得到一些解决问题的帮助 您必须在chrome浏览器上安装它,方法是将下面的代码保存为文件名为“test.user.js”的文件 然后将该文件拖到浏览器的“扩展名”选项卡中(>settings>extensions on chrome)并激活它。 然后在浏览器上打开,单击活动拍卖,检查每次有人出价时都会出现投标人名称的元素,并将该id复制到“GO MONITOR”上方的文本字段中(看起来像Javascript JS脚本上未定义的变量数组,javascript,jquery,arrays,google-chrome,undefined,Javascript,Jquery,Arrays,Google Chrome,Undefined,想知道是否有人能帮上忙 我有一个脚本,它拒绝在我的浏览器的最新版本上工作(在旧版本中工作),并希望得到一些解决问题的帮助 您必须在chrome浏览器上安装它,方法是将下面的代码保存为文件名为“test.user.js”的文件 然后将该文件拖到浏览器的“扩展名”选项卡中(>settings>extensions on chrome)并激活它。 然后在浏览器上打开,单击活动拍卖,检查每次有人出价时都会出现投标人名称的元素,并将该id复制到“GO MONITOR”上方的文本字段中(看起来像mbal1_
mbal1_ac2560454_bidder
)。然后单击“GO MONITOR”,图表开始显示
我遇到的主要问题是:在“GO MONITOR”按钮下,它显示未定义的
,而不是记录玩家的名字,因为他们的出价与相对出价计数有关
第二个,Chrome根本不显示图形,而是渲染一个纯色灰色背景。在Firefox上,图形确实有效,但仍然没有玩家名单
代码如下:
(function(){
var madbidMonitor = {};
madbidMonitor = function() {
this.layerMonitor = null;
this.players = Array();
this.totalPujas = 0;
this.lastPlayerName = "";
this.oContent = null;
this.timer=0;
this._init();
this.chart = null;
return this;
};
madbidMonitor.prototype = {
_init:function() {
var _this = this;
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
var layer = document.createElement("div");
layer.style.position = 'absolute';
layer.style.top = "0px";
layer.style.right = "0px";
layer.style.background = "#555";
layer.style.border = "1px solid #fff";
layer.style.color = "#fff";
layer.style.width = "140px";
layer.style.height = y+"px";
layer.style.overflow ='scroll';
layer.style.fontSize = '10px';
document.body.appendChild(layer);
this.oContent = layer;
//
var o = document.createElement("div");
o.id = 'madbidmonchart';
o.style.position = 'fixed';
o.style.bottom = "20px";
o.style.left = "0px";
o.style.background = "#555";
o.style.border = "1px solid #333";
o.style.color = "#fff";
o.style.width = (x-160)+"px";
o.style.height = (y-600)+"px";
document.body.appendChild(o);
//
var idDivText = this._getRandomID();
var idDivBtn = this._getRandomID();
layer.innerHTML += '<input type="text" id="'+idDivText+'"/>';
layer.innerHTML += '<input id="'+idDivBtn+'" type="button" value="GO MONITOR"/>';
//
var script = document.createElement('script');
script.onload = function(){_this.Charts()};
script.src = "http://code.highcharts.com/highcharts.js";
document.getElementsByTagName('head')[0].appendChild(script);
//
document.getElementById(idDivBtn).addEventListener('click', function(){
_this.layerMonitor = document.getElementById(document.getElementById(idDivText).value);
setInterval(function(){_this.IntervalMonitor.call(_this)},100);
});
}
,
_getRandomID : function(){
return Math.floor((Math.random()*100000000)+1);
}
,
findPlayer : function(name) {
for(var n=0; n<this.players.length; n++) {
if(this.players[n].name==name) return n;
}
return false;
}
,
IntervalMonitor : function() {
this.timer += 0.1;
if(!this.layerMonitor) return;
this.oContent.style.top = window.pageYOffset+"px";
if(this.layerMonitor.style.display=='none'){
this.lastPlayerName='';
return;
}
var actualPlayerName = this.layerMonitor.innerText;
var actualPlayer = this.findPlayer(actualPlayerName);
if(actualPlayer===false) {
this.players.push({name:actualPlayerName, pujas:1, history: [this.timer]});
this.chart.addSeries({name:actualPlayerName, data:[[this.timer,1]]});
this.lastPlayerName=actualPlayerName;
this.totalPujas++;
}
else {
if(this.lastPlayerName!=actualPlayerName){
this.players[actualPlayer].pujas++;
this.players[actualPlayer].history.push(this.timer);
this.chart.series[actualPlayer].addPoint([this.timer, this.players[actualPlayer].pujas]);
this.lastPlayerName=actualPlayerName;
this.totalPujas++;
}
}
this.Paint();
}
,
Paint : function() {
this.oContent.innerHTML = "<b>Total pujas:</b> " + this.totalPujas+"<br>";
for(var n=0; n<this.players.length; n++){
this.oContent.innerHTML += "<b>"+this.players[n].name+":</b> "+this.players[n].pujas+"<br>";
}
}
,
Charts : function() {
this.chart = new Highcharts.Chart({
chart: {
renderTo: 'madbidmonchart',
type: 'line',
animation: false,
zoomType: 'x'
},
title: {
text: 'MADBID APUESTAS MONITOR'
},
subtitle: {
text: 'by <a href="http://www.polimalo.com/" target="_blank">PoliMalo.com</a> / <a href="http://polilabs.com/" target="_blank">PoliLabs.com</a>'
},
xAxis: {
type: 'linear'
},
yAxis: {
title: {
text: 'Apuestas'
},
min: 0
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+ (this.x/60.0).toFixed(2) +' min<br> '+ this.y+" apuestas";
}
},
plotOptions: {
series: {
marker: {
radius: 2
},
lineWidth: 1
}
},
series: []
});
}
}
new madbidMonitor();
})();
(函数(){
var madbidMonitor={};
madbidMonitor=函数(){
this.layerMonitor=null;
this.players=Array();
这个.totalPujas=0;
此.lastPlayerName=“”;
this.oContent=null;
这个计时器=0;
这个;
this.chart=null;
归还这个;
};
madbidMonitor.prototype={
_init:function(){
var_this=这个;
var w=窗口,
d=文件,
e=d.documentElement,
g=d.getElementsByTagName('body')[0],
x=w.innerWidth | | e.clientWidth | | g.clientWidth,
y=w.内部高度| | e.倾斜度| | g.倾斜度;
var层=document.createElement(“div”);
layer.style.position='绝对';
layer.style.top=“0px”;
layer.style.right=“0px”;
layer.style.background=“#555”;
layer.style.border=“1px solid#fff”;
layer.style.color=“#fff”;
layer.style.width=“140px”;
layer.style.height=y+“px”;
layer.style.overflow='scroll';
layer.style.fontSize='10px';
document.body.appendChild(层);
this.oContent=层;
//
var o=document.createElement(“div”);
o、 id='madbidmonchart';
o、 style.position='fixed';
o、 style.bottom=“20px”;
o、 style.left=“0px”;
o、 style.background=“#555”;
o、 style.border=“1px实心#333”;
o、 style.color=“#fff”;
o、 style.width=(x-160)+“px”;
o、 样式高度=(y-600)+“px”;
文件.正文.附件(o);
//
var idDivText=这个;
var idDivBtn=这个;
layer.innerHTML+='';
layer.innerHTML+='';
//
var script=document.createElement('script');
script.onload=function(){u this.Charts()};
script.src=”http://code.highcharts.com/highcharts.js";
document.getElementsByTagName('head')[0].appendChild(脚本);
//
document.getElementById(idDivBtn).addEventListener('click',function()){
_this.layerMonitor=document.getElementById(document.getElementById(idDivText.value));
setInterval(function(){this.IntervalMonitor.call({this)},100);
});
}
,
_getRandomID:函数(){
返回Math.floor((Math.random()*100000000)+1);
}
,
findPlayer:函数(名称){
对于(var n=0;n首先,存在以下脚本错误(即使未加载脚本):
这很可能会导致进一步的问题,因此您需要首先解决这个问题
然后:由于Chrome认为highcharts.com中的脚本不安全,因此无法显示您的图形:
Refused to load the script 'http://code.highcharts.com/highcharts.js' because it violates the following Content Security Policy directive: "script-src https://*.facebook.com http://*.facebook.com https://*.fbcdn.net http://*.fbcdn.net *.facebook.net *.google-analytics.com *.virtualearth.net *.google.com 127.0.0.1:* *.spotilocal.com:* chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl 'unsafe-inline' 'unsafe-eval' https://*.akamaihd.net http://*.akamaihd.net *.atlassolutions.com".
您还存在混合http
和https
连接的问题:
[blocked] The page at 'https://platform.twitter.com/widgets/hub.html' was loaded over HTTPS, but ran insecure content from 'http://code.highcharts.com/highcharts.js': this content should also be loaded over HTTPS.
我的建议是:找一个能帮你解决这些Javascript问题的人。如果你不知道自己在做什么,这会让你发疯
编辑
似乎有人在积极地处理该页面。我上面描述的第一个错误现在已经消失了。到目前为止您尝试了什么?有什么想法可以解决问题吗?您所做的哪些更改不起作用?我只尝试了一些小的更改,例如使用[]更改数组()但我相信还有更多。我只是不熟悉java语言,我主要使用html和css。我想这不是很有帮助。你是一个超级明星!你的帮助足以让我明白:)错误是对脚本的不安全调用,所以我将所有脚本调用在内部重定向到我的127.0.0.1服务器,复制了文件,现在可以工作了!非常感谢:)问题:您使用了什么调试程序来获得这些评论?(“拒绝”等)很高兴这有帮助。Chrome开发者工具(在Mac上:查看->开发者->开发者工具)。在Safari或Firefox开发工具中看起来也一样。
[blocked] The page at 'https://platform.twitter.com/widgets/hub.html' was loaded over HTTPS, but ran insecure content from 'http://code.highcharts.com/highcharts.js': this content should also be loaded over HTTPS.