From: Karim Hamidou Date: Sat, 29 May 2021 23:40:16 +0000 (-0700) Subject: Plugin works! X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=77de66045438e82bbe554341fc5f2cf58fb23b0c;p=infinity-pools.git Plugin works! --- diff --git a/balloons.js b/balloons.js new file mode 100644 index 0000000..bba978e --- /dev/null +++ b/balloons.js @@ -0,0 +1,66 @@ +var windowWidth = window.innerWidth; +var windowHeight = window.innerHeight; + +function pickANumber(max, min) { + return Math.random() * (max - min + min) + min; +} + +function changeColors(el) { + el.removeClass(); + var random = Math.floor(pickANumber(5,1)); + el.addClass('bln-'+random+'-clone'); +} + +function resetBalloon(el) { + changeColors(el); + + var scale = (pickANumber(0.9,0.5)).toFixed(1); + el.css('transform', 'scale(' + scale + ')'); + + var x = Math.floor(Math.random() * windowWidth); + el.css('left', x); + var y = Math.floor(Math.random() * 300 + windowHeight); + el.css('top', y); + releaseBalloon(el); +} + +function releaseBalloon(el) { + var maxbllnSpeed = Math.floor(Math.random() * 20000 + 3000); + var wind = Math.floor(Math.random() * + 50); + var rotate = Math.floor(Math.random() * 860) + 100; + + el.animate({top: '-150px', left: '+=' + wind + 0}, { + step: function() { + el.css({ + transform: 'rotate('+rotate+'deg)', + transition: 'transform '+ maxbllnSpeed * .001 +'s linear' + }); + }, + duration: maxbllnSpeed, + easing: 'linear', + complete: function() { + resetBalloon(el); + } + }); +} + +function blowUpBalloons() { + for (i = 0; i < 100; i++) { + var el = $('.bln-1').clone(); + el[0].style.display = 'block'; + el.appendTo('.blns'); + + resetBalloon(el); + + var position = el.position(); + + if (position.top > windowHeight || position.left > windowWidth || position.left < -100) { + resetBalloon(el); + } + } +} + +$(document).ready(function() { + blowUpBalloons(); +}) + diff --git a/frame.html b/frame.html new file mode 100644 index 0000000..c6445b6 --- /dev/null +++ b/frame.html @@ -0,0 +1,21 @@ + + + + + + + + +
+ +
+ + + + + diff --git a/index.html b/index.html deleted file mode 100644 index ed7664d..0000000 --- a/index.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - -
- -
- - - - - diff --git a/manifest.json b/manifest.json index f17bb8f..24c85c3 100644 --- a/manifest.json +++ b/manifest.json @@ -6,6 +6,9 @@ "description": "An extension to hide Twitter's feed after 30 mins every day.", "update_url": "https://khamidou.com/extensions/update.xml", "permissions": ["storage"], + "web_accessible_resources": [ + "frame.html" + ], "content_scripts": [ { "matches": ["*://*.twitter.com/*"], diff --git a/start.js b/start.js index a5ddbdc..717b718 100644 --- a/start.js +++ b/start.js @@ -33,7 +33,7 @@ var refreshConfig = async function() { let data = await p; - let defaultConfig = {currentDay: getFormattedDate(), remainingMinutes: 15} + let defaultConfig = {currentDay: getFormattedDate(), remainingMinutes: 30} if (data.config == {} || data.config == undefined) { Object.assign(config, data.config); return; @@ -43,7 +43,7 @@ var refreshConfig = async function() { // if this is a new day, reset the config. Object.assign(config, defaultConfig); return; - else { + } else { Object.assign(config, data.config); return; } @@ -98,7 +98,15 @@ async function mainEventHandler() { await refreshConfig(); console.log(config.remainingMinutes); if (config.remainingMinutes <= 0) { - alert("you're at time!"); + // Avoid recursive frame insertion... + var extensionOrigin = 'chrome-extension://' + chrome.runtime.id; + if (!location.ancestorOrigins.contains(extensionOrigin)) { + var iframe = document.createElement('iframe'); + // Must be declared at web_accessible_resources in manifest.json + iframe.src = chrome.runtime.getURL('frame.html'); + window.location.href = iframe.src; + } + return; }