Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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