Created
July 6, 2017 12:22
-
-
Save BruhKofi/4d494a667055313cef7479fca978255d to your computer and use it in GitHub Desktop.
evaluator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getCurrentWeek = function(){ | |
var d = new Date(); | |
d.setHours(0,0,0,0); | |
d.setDate(d.getDate()+4-(d.getDay()||7)); | |
return [d.getFullYear(), Math.ceil((((d-new Date(d.getFullYear(),0,1))/8.64e7)+1)/7)]; | |
}; | |
var skipButton = document.querySelectorAll('[data-translation-id="account-area.my-deliveries.skip-week"]')[0]; | |
var isActive = skipButton.innerHTML | |
if (( skipButton.innerHTML ) === "Pausieren") { | |
console.log("ready for pause"); | |
skipButton.addEventListener('click', function() { | |
var CurrentWeekNumber = getCurrentWeek()[1]; | |
var selectedWeek = window.location.pathname.split( '/' )[4].slice(-2); | |
if ( (selectedWeek - CurrentWeekNumber) <= 5 ) { | |
console.log("true"); | |
var canBBQ = 'true'; | |
} else{ | |
console.log("false"); | |
var canBBQ = 'false'; | |
} | |
return canBBQ; | |
}, false) | |
} else { | |
console.log("not ready for pause"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment