NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Leetcode timer // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://leetcode.com/problems/* // @match https://leetcode.com/* // @require https://leetcode.com/static/jquery/dist/jquery.min.js // @grant none // @license MIT // ==/UserScript== $('.side-bar').hide(); $('.like-and-dislike').hide(); var $j = jQuery.noConflict(); $j(document).ready(function() { $j('.side-bar').hide(); $j('#lc_navbar').append("<button align='center' id='timer'>Start Problem</button>"); $j( "#timer" ).click(function(){ $('#timer').html(''); var difficulty = $j('.question-info ul li:nth-child(5)').text(); var diff = 30, score=0; if(difficulty.indexOf("Hard") !== -1) {diff = 60;score=500;} if(difficulty.indexOf("Medium") !== -1) {diff = 45;score=250;} if(difficulty.indexOf("Easy") !== -1) {diff = 25;score=100;} // Update the count down every 1 second var countDownDate = new Date(new Date().getTime() + diff*60000); $j('#question-detail-app').prepend("<h2 align='center' id='timer2' style='position: fixed;top: 1em;right: 1em;'> Starting Now!</h2>"); $j('#submission-form-app').prepend("<h2 align='center' id='timer2' style='position: fixed;top: 1em;right: 1em;'> Starting Now!</h2>"); var x = setInterval(function() { var now = new Date().getTime(); var distance = countDownDate - now; var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000); if(minutes%10===0) score = score - 20; $j('#timer2').text(minutes + " min" ); // If the count down is over, write some text if (distance < 0) { document.getElementById("timer2").innerHTML = "TIME UP!!"; } $j('.list-group').hide(); $j('.like-and-dislike').hide(); $j('#lc_navbar').hide(); }, 1000); }); });