diff options
author | joak <joak@nospace.at> | 2017-01-13 15:18:08 +0100 |
---|---|---|
committer | joak <joak@nospace.at> | 2017-01-13 15:18:08 +0100 |
commit | e955b48277bc86a41744078c032f44eeb53e38e6 (patch) | |
tree | 6b3841facbbc07697c2d7d70e84d6c7897ceb934 /2015_locomotivebrowser/firefox/script.js | |
parent | ea824be9f5fa9ae470db515ab3f6d3996a9cae0f (diff) |
new icon mirror
Diffstat (limited to '2015_locomotivebrowser/firefox/script.js')
-rw-r--r-- | 2015_locomotivebrowser/firefox/script.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/2015_locomotivebrowser/firefox/script.js b/2015_locomotivebrowser/firefox/script.js new file mode 100644 index 0000000..74c7805 --- /dev/null +++ b/2015_locomotivebrowser/firefox/script.js @@ -0,0 +1,75 @@ +var audioElement; +var audioElement2; +var interer; +var start = false; + +chrome.runtime.onMessage.addListener( + function(request, sender, sendResponse) { + if(request.greeting == "start"){ + if(start == false){ + start = true; + //start + + var link = document.createElement("link"); + link.href = chrome.extension.getURL("animationlocomotive.css"); + link.type = "text/css"; + link.rel = "stylesheet"; + document.getElementsByTagName("head")[0].appendChild(link); + + audioElement = document.createElement('audio'); + audioElement.setAttribute('src', chrome.extension.getURL("start.mp3")); + audioElement.setAttribute('autoplay', 'autoplay'); + audioElement2 = document.createElement('audio'); + audioElement2.setAttribute('src', chrome.extension.getURL("sound.mp3")); + audioElement2.setAttribute('autoplay', 'autoplay'); + audioElement2.setAttribute('loop', 'true'); + + $('html').css({"-webkit-animation-duration": "3s"}); + $('html').css({"-webkit-animation-name": "locomotivestart"}); + $('html').css({"-webkit-animation-timing-function": "linear" }); + $('html').css({"-webkit-animation-play-state": "running"}); + $('html').css({"-webkit-animation-iteration-count": "1" }); + + audioElement.addEventListener("ended", function() { + audioElement2.play(); + }, true); + + //normal + var interval = 3; + if(start == true){ + inter = setTimeout(function(){ + $('html').css({"-webkit-animation-duration": String(interval)+"s"}); + $('html').css({"-webkit-animation-name": "locomotiveanimation"}); + $('html').css({"-webkit-animation-timing-function": "linear" }); + $('html').css({"-webkit-animation-play-state": "running"}); + $('html').css({"-webkit-animation-iteration-count": "infinite" }); + stuff(); + }, 2900); + } + function stuff(){ + if (interval > 0.31 && start == true){ + interval = interval - 0.3; + $('html').css("-webkit-animation", "none").hide().show(0); + //$('html').css({"-webkit-animation-play-state": "paused"}); + text = '-webkit-animation-duration: '+String(interval)+'s !important;'; + $('html').css({"-webkit-animation-duration": String(interval)+"s"}); + //$('html').css('cssText', text); + $('html').css({"-webkit-animation-name": "locomotiveanimation"}); + $('html').css({"-webkit-animation-timing-function": "linear" }); + $('html').css({"-webkit-animation-play-state": "running"}); + $('html').css({"-webkit-animation-iteration-count": "infinite" }); + interer = setTimeout(stuff, interval*1000); + } else { + } + } + } + } + if(request.greeting == "stop"){ + start = false; + clearTimeout(interer); + $('html').css("-webkit-animation", "none"); + audioElement.src = ""; + audioElement2.src = ""; + } + } +); |