• HD

    萌学园:寻找盘古

  • HD

    幸福城市

  • HD中字

    诡丝

  • HD

    复身犯

', weight: 30 }, { code: '', weight: 50 } ]; // 计算总权重 var totalWeight = ads.reduce(function(sum, ad) { return sum + ad.weight; }, 0); // 随机选择一个广告 var randomIndex = Math.floor(Math.random() * totalWeight); var currentWeight = 0; var selectedAd = null; for (var i = 0; i < ads.length; i++) { currentWeight += ads[i].weight; if (currentWeight >= randomIndex) { selectedAd = ads[i]; break; } } // 将选中的广告代码插入到页面中的广告容器内 var adContainer = document.getElementById('ad-container'); adContainer.innerHTML = selectedAd.code;