Last active
September 26, 2018 06:24
-
-
Save ylogx/b59585aac20095414f1299744cdc30b6 to your computer and use it in GitHub Desktop.
A bookmarklet to find various zomato resource properties. To use, copy this code and paste it in URL field of a new bookmark.
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
javascript: void | |
function($) { | |
var loadBookmarklet = function($) { | |
(function() { | |
if ("www.zomato.com" == document.domain) { | |
var msg = ""; | |
try { | |
splits = $('meta[property="al:android:url"]').attr("content").split("/"); | |
const id = splits[3], | |
page_type = splits[2]; | |
switch (page_type) { | |
case "r": | |
msg += "res_id: " + id; | |
break; | |
case "review": | |
msg += "review_id: " + id; | |
break; | |
case "u": | |
msg += "user_id: " + id; | |
break; | |
default: | |
msg += "Page type unknow." | |
} | |
} catch (err) { | |
console.log(err) | |
} | |
try { | |
city_id = $("input[name=city]").attr("value"), msg += "\ncity_id: " + city_id | |
} catch (err) { | |
console.log(err) | |
} | |
"" != msg && (console.log(msg), alert(msg)) | |
} | |
})() | |
}, | |
hasJQuery = $ && $.fn && parseFloat($.fn.jquery) >= 1.7; | |
if (hasJQuery) loadBookmarklet($); | |
else { | |
var s = document.createElement("script"); | |
s.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js", s.onload = s.onreadystatechange = function() { | |
var state = this.readyState; | |
state && "loaded" !== state && "complete" !== state || loadBookmarklet(jQuery.noConflict()) | |
} | |
} | |
document.getElementsByTagName("head")[0].appendChild(s) | |
}(window.jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment