Skip to content

Instantly share code, notes, and snippets.

@Mukundan314
Last active March 14, 2019 04:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Mukundan314/50d8450b7b5acd68a6a915b70bb5f66f to your computer and use it in GitHub Desktop.
Save Mukundan314/50d8450b7b5acd68a6a915b70bb5f66f to your computer and use it in GitHub Desktop.
Codejam greasemonkey script
// ==UserScript==
// @name code jam
// @version 2.1
// @author Mukundan Senthil
// @include https://codingcompetitions.withgoogle.com/*
// @require http://code.jquery.com/jquery-latest.js
// @require https://gist.githubusercontent.com/BrockA/2625891/raw/waitForKeyElements.js
// @grant none
// ==/UserScript==
const urlRegex = /^\/codejam\/round/
const urlProblemRegex = /^\/codejam\/round\/[^\/]+\/[^\/]+/
const css = `
.mdc-top-app-bar--fixed-adjust--additional {
padding-top: 120px !important;
}
.section-row {
padding-top: 1% !important;
}
.competition-interface-page .pane-interface {
flex-direction: column !important;
}
.pane-interface__left {
flex-basis: 90% !important;
}
.pane-interface__right {
padding-top: 0.5% !important;
flex-basis: 10% !important;
flex-direction: row !important;
}
.problem-statement-string {
padding-bottom: 1rem !important;
}
.tmp {
display: flex;
height: 100%;
}
.tmp__left {
flex-basis: 20%;
padding-top: 4rem;
}
.tmp__right {
flex-basis: 80%;
}
`
const style = $('<style>', { type: 'text/css' }).html(css)
function removeNode (node) { node.remove() }
if (urlRegex.test(location.pathname)) {
waitForKeyElements('.problems-bar-graphs', removeNode)
waitForKeyElements('.rounds-header', removeNode)
waitForKeyElements('.problem-editor__window', removeNode)
waitForKeyElements('.problem-editor__actions__switch', removeNode)
waitForKeyElements('head', function (node) { node.append(style) })
}
$(document).ready(function () {
if (urlProblemRegex.test(location.pathname)) {
let problems = $('.mdc-list').eq(1).clone().addClass('tmp__left')
problems.on('click', '.mdc-list-item', function () {
location.href = $(this).attr('data-value')
})
let a = $('<div></div>')
a.addClass('tmp')
problems.appendTo(a)
$('.pane-interface').addClass('tmp__right').appendTo(a)
a.appendTo($('.mdc-drawer-app-content'))
}
})
var lastPathStr = location.pathname
setInterval(function () {
if (lastPathStr !== location.pathname && !(urlProblemRegex.test(location.pathname) && urlProblemRegex.test(lastPathStr))) {
lastPathStr = location.pathname
location.reload()
}
}, 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment