'Window.open() Width + Height Resize Doesn't Work
I am working on a google extension that opens four random pop-ups every hour (and opens different pop-ups during the day and night).
The pop-up sizes vary so I set each size of the pop-up url but it does not seem to work as seen in the picture. Does anyone have any ideas why it is not working?
Thank you so much :')
function showPopup() {
let date = new Date();
let h = date.getHours();
if(h > 5 && h < 20)
{
var Popups = [
{
url: 'https://looking4love.glitch.me/', // Day time -- Gorse
width: 400,
height: 530,
},
{
url: 'https://meetme2day.glitch.me/', //Canada goose
width: 400,
height: 530,
},
{
url: 'https://chat2me.glitch.me/', // Cow Parsley
width: 400,
height: 530,
},
{
url: 'https://meet-me-2nite.glitch.me/', //Eurasian Coot
width: 530,
height: 400,
},
{
url: 'https://meetmenow.glitch.me/', // Hawthorn
width: 400,
height: 530,
},
{
url: 'https://looking4relatioship.glitch.me/', // Bluebell
width: 400,
height: 530,
},
{
url: 'https://availablenow.glitch.me/', //Moss
width: 400,
height: 530,
},
{
url: 'https://cute-single-needs-lov.glitch.me/', // Poppies
width: 530,
height: 400,
},
];
var a = Popups.splice(Math.floor(Math.random() * Popups.length - 1), 1)[0];
var b = Popups.splice(Math.floor(Math.random() * Popups.length - 1), 1)[0];
var c = Popups.splice(Math.floor(Math.random() * Popups.length - 1), 1)[0];
var d = Popups.splice(Math.floor(Math.random() * Popups.length - 1), 1)[0];
console.log(a,b,c,d);
// daytime
window.open(a.url, 'Go Outside!', `directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0,scrollbars=no,resizable=no,top=20,left=20,width=${a.width},height=${a.height}`);
setTimeout(() => {
window.open(b.url, 'Go Outside! 02', `directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0,scrollbars=no,resizable=no,top=200,left=200,width=${b.width},height=${b.height}`);
}, 1000);
setTimeout(() => {
window.open(c.url, 'Go Outside! 03', `directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0,scrollbars=no,resizable=no,top=50,left=620,width=${c.width},height=${c.height}`);
}, 2000);
setTimeout(() => {
window.open(d.url, 'Go Outside! 04', `directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0,scrollbars=no,resizable=no,top=100,left=820,width=${d.width},height=${d.height}`);
}, 3000);
}
else
{
var Popups = [
{
url: 'https://feeling-lonely.glitch.me/', // Night time -- Robin
width: 400,
height: 529,
},
{
url: 'https://talk-2-me.glitch.me/', // Mallard
width: 400,
height: 529,
},
{
url: 'https://looking4relatioship.glitch.me', // Blue bell
width: 400,
height: 529,
},
{
url: 'https://chat2metonite.glitch.me/', //Fuchisas
width: 400,
height: 529,
},
{
url: 'https://freetonight.glitch.me/', //Viviparous
width: 400,
height: 529,
},
{
url: 'https://chat-tonight.glitch.me/', //Teasel
width: 400,
height: 529,
},
{
url: 'https://free-tonight.glitch.me/', //Six-spot
width: 529,
height: 400,
},
];
var a = Popups.splice(Math.floor(Math.random() * Popups.length - 1), 1)[0];
var b = Popups.splice(Math.floor(Math.random() * Popups.length - 1), 1)[0];
var c = Popups.splice(Math.floor(Math.random() * Popups.length - 1), 1)[0];
var d = Popups.splice(Math.floor(Math.random() * Popups.length - 1), 1)[0];
// nighttime
window.open(a.url + "?test=abc", 'Go Outside!', `directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0,scrollbars=no,resizable=no,top=20,left=20,width=${a.width},height=${a.height}`);
setTimeout(() => {
window.open(b.url + "?test=abc", 'Go Outside! 02', `directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0,scrollbars=no,resizable=no,top=200,left=200,width=${b.width},height=${b.height}`);
}, 1000);
setTimeout(() => {
window.open(c.url + "?test=abc", 'Go Outside! 03', `directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0,scrollbars=no,resizable=no,top=50,left=620,width=${c.width},height=${c.height}`);
}, 2000);
setTimeout(() => {
window.open(d.url + "?test=abc", 'Go Outside! 04', `directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0,scrollbars=no,resizable=no,top=100,left=820,width=${d.width},height=${d.height}`);
}, 3000);
}
let paragraphs = document.getElementsByTagName('body');
for (elt of paragraphs) {
elt.style['background-color']= '#000000';
elt.style['color']= '#000000';
// elt.style['filter'] = 'blur(50px)';
// elt.innerText = "";
}
}
setInterval(() => {
let d = new Date();
let m = d.getMinutes();
let s = d.getSeconds();
if(s % 20 == 0) // this for testing
// if(m == 21 && s == 0) // this for once an hour
{
// it is zero minutes and zero seconds...
showPopup();
}
}, 500);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
