Created
June 30, 2012 21:14
-
-
Save gkatsev/3025550 to your computer and use it in GitHub Desktop.
Evaluate division for percent in goodreads' update box.
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
// ==UserScript== | |
// @name Percent-eval | |
// @namespace http://gkatsev.com/percenteval | |
// @description Evaluate division for percent in goodreads' update box | |
// @include *://*goodreads.*/* | |
// @version 1 | |
// ==/UserScript== | |
window.addEventListener('DOMContentLoaded' | |
, function(){ | |
var inputs = document.querySelectorAll('#user_status_percent') | |
console.log(inputs) | |
Array.prototype.forEach.call(inputs, function(el){ | |
el.addEventListener('blur', function(ev){ | |
var value = el.value | |
if(/\d+\/\d+/.test(value)){ | |
var newVal = Math.ceil(eval(value)*100) | |
el.value=newVal | |
} | |
}, false) | |
}) | |
} | |
, false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment