Skip to content

Instantly share code, notes, and snippets.

@rithvikvibhu
Created January 14, 2018 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rithvikvibhu/5fa9addc04d098d64b144f0be9099e01 to your computer and use it in GitHub Desktop.
Save rithvikvibhu/5fa9addc04d098d64b144f0be9099e01 to your computer and use it in GitHub Desktop.
Greasemonkey script to inject link into Entrar
// ==UserScript==
// @name DPS Canteen for Entrar
// @version 1
// @include https://entrar.in/*
// @grant none
// ==/UserScript==
// Get admission number
var admid = document.getElementById("welcome-user").innerText.split('\n')[2].replace('/', '')
// Insert form
var f = document.createElement("form");
f.setAttribute('method',"post");
f.style.display = 'none';
f.setAttribute('action',"https://api.dpscanteen.ml/entrar/login");
var i = document.createElement("input");
i.setAttribute('type',"text");
i.setAttribute('value', admid);
i.setAttribute('name',"admid");
f.appendChild(i);
var s = document.createElement("input");
s.setAttribute('type',"submit");
s.setAttribute('value',"Submit");
f.appendChild(s);
document.getElementsByTagName('body')[0].appendChild(f);
// Insert link
var li = document.getElementById("smoothmenu1").children[0].lastElementChild;
var clone = li.cloneNode(true);
clone.text = 'Canteen';
clone.firstChild.innerText = 'Canteen Portal'
clone.firstChild.setAttribute('target', '_self');
clone.firstChild.href = 'javascript:{}'
clone.onclick = function() { f.submit() }
document.getElementById("smoothmenu1").children[0].appendChild(clone);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment