我的Javascript代码出错

Error in my Javascript code

本文关键字:出错 代码 Javascript 我的      更新时间:2023-09-26

每当我运行代码时,我都会收到错误,如果有人能解释出了什么问题或给我看一个修复的版本?我将非常感谢

混合内容:

位于'的页面https://www.roblox.com/catalog/'是通过HTTPS加载的,但请求了一个不安全的XMLHttpRequest端点'http://c3.rbxcdn.com/4b192cd410398472f25d7aea541a352c"。此请求已被阻止;必须通过HTTPS提供内容。

代码:

var globeid = 0
var priceUnder = 5000

function check(z){
$.get(z, function(data){
          if ($(data).find('#ctl00_cphRoblox_LimitedEditionRemaining').length) {
                var check = $(data).find('#BuyWithRobux').children('div').data()
                var Token = data.match(/Roblox.XsrfToken.setToken([^)]+)/)[1].match(/[^(']+/)[0]
                if (check['expectedPrice'] <= priceUnder) {
                    $.post('https://www.roblox.com/api/item.ashx?rqtype=purchase&productID=' + check["productId"] + '&expectedCurrency=1&expectedPrice=' + check["expectedPrice"] + '&expectedSellerID=1')
                    console.log('Purchased: ' + check["itemName"] + " | " + check["itemId"] + " for " + check["expectedPrice"])
                }
          }
})
}
function checkifnewlim() {
    $.get("https://www.roblox.com/asset/?id=261522650").success(function(r) {
        r = decodeURIComponent(r);
        r = JSON.parse(r.substring(r.indexOf("{"), r.lastIndexOf("}") + 1));
        var notifications = r
        for (var info in notifications) {
            var currid = notifications[info]["id"]
            if (currid > globeid) {
                console.log("NEW ITEM...")
                globeid = currid
                notificationpopup(notifications[info])
                var nn = notifications[info]
                var url = nn.url.split('&')[0]
                check(url)
            }
        }
    })
    function notificationpopup(n) {
        var notification = new Notification(n.lite, {
            icon: n.icon,
            body: n.header + "'n" + "Price: " + n.items.Price + "'n'n" + "Autobuy: OFF"
        });
var url = n.url.split('&')[0]
        notification.onclick = function() {
            console.log("NOTIFICATION SUCCESS!");
            window.open(url);
        }
    }
}
setInterval(function() {
    checkifnewlim()
}, 100)

如果你的代码在HTTPS页面上运行,你只能从其他域请求HTTPS内容,任何试图与HTTP资源对话的xhr请求都将被浏览器阻止。如果您试图访问的内容在您的域中,请确保它是通过HTTPS提供的。否则你可以做两件事之一:

  • 如果你有一些服务器端代码在运行,你可以尝试添加一个钩子来代理你的调用
  • 人们试图通过使用像这里这样的第三方库来解决这个问题,这对你来说隐藏了复杂性