gpt4 book ai didi

javascript - 尝试使用 Tempermonkey 随机更改 Steam 背景,总是出现 "Parsing Error: Unexpected Token"错误

转载 作者:行者123 更新时间:2023-11-28 03:06:55 25 4
gpt4 key购买 nike

这是我的代码

(function() {
'use strict';

var imagesArray = [

"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/items/583660/361fda7dfb819158079afbf50b7ca13d1ffa6468.jpg",
"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/items/203770/c6f5ea583b7883659e35fbedf1b21220dc230dda.jpg"

];

function setBackground(){
const background = document.querySelector('.profile_background_image_content')
const randomImage = imagesArray[Math.floor(Math.random() * imagesArray.length + 1)]
background.style.backgroundImage = url(${randomImage}) !important
}

setBackground()

})();

好吧,老实说,我不知道为什么它会给出错误,或者我正在做正确的事情。我将不胜感激的帮助。

最佳答案

你应该把它包装起来

url(${randomImage}) !important

像这样的反引号

   `url(${randomImage}) !important`

关于javascript - 尝试使用 Tempermonkey 随机更改 Steam 背景,总是出现 "Parsing Error: Unexpected Token"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60533780/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com