Random URL redirect from array

前端 未结 8 1220
刺人心
刺人心 2021-01-27 05:37

/** * Political Animals * contentscript.js is loaded on each page(s) listed in manifest.json * This plugin replaces all the images on the website of news sites with pic

8条回答
  •  温柔的废话
    2021-01-27 06:02

    Try the following:

    var acceptedWebsites =['http://www.cnn.com/', 'www.nytimes.com', 'www.latimes.com', 'http://www.washingtonpost.com/', 'http://www.nbcnews.com/', 'http://www.foxnews.com/'];
        var number = Math.floor(Math.random() * acceptedWebsites.length);
    

    number will generate a random number between 1 and the number of entries in your acceptedwebsites array.

提交回复
热议问题