Created
January 30, 2016 20:09
-
-
Save oboenikui/02a301c24f2a712ee256 to your computer and use it in GitHub Desktop.
Cookpadで材料を指定するもメニューが多すぎて選びきれないときに勝手に選んでくれるやつ
This file contains hidden or 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
function parseQuery(query) { | |
var result = {}; | |
var vars = query.split('&'); | |
for (var i = 0; i < vars.length; i++) { | |
var pair = vars[i].split('='); | |
result[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); | |
} | |
return result; | |
} | |
var params = parseQuery(__load_parameters); | |
var selected = ~~(Math.random() * params.rh); | |
$.get(`${location.origin + location.pathname}?page=${selected/10}&recipe_hit=${params.rh}`, function(data){ | |
var div = document.createElement("div"); | |
div.innerHTML = data | |
div.getElementsByClassName("recipe-title font13")[selected % 10].click(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment