Skip to content

Instantly share code, notes, and snippets.

@gkatsev
Created June 30, 2012 21:14
Show Gist options
  • Save gkatsev/3025550 to your computer and use it in GitHub Desktop.
Save gkatsev/3025550 to your computer and use it in GitHub Desktop.
Evaluate division for percent in goodreads' update box.
// ==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