开发者

Chrome Javascript Bookmarklet Problem

开发者 https://www.devze.com 2023-03-30 02:09 出处:网络
I made this simple bookmarklet to get the Facebook id from a Facebook user\'s profile. var fb_idsource=document.getElementById(\"pro开发者_StackOverflowfile_action_send_message\").href;

I made this simple bookmarklet to get the Facebook id from a Facebook user's profile.

var fb_idsource=document.getElementById("pro开发者_StackOverflowfile_action_send_message").href;
var fb_userid=fb_idsource.match(/\d+/g);
alert(fb_userid);

Open someone's facebook profile with a send "Message" button at top right corner. It will work if you paste it and run via Google Chrome developer console, but not working when used as bookmarklet by adding "javascript: " prefix.

Any ideas how to make it work?? Thx for any advice.


Drag and drop this into your bookmark bar, works great!

http://jsfiddle.net/wesbos/Evzek/

<a href='javascript:(function(){var fb_idsource=document.getElementById("profile_action_send_message").href; var fb_userid=fb_idsource.match(/\d+/g); alert(fb_userid);})();'>Get ID</a>

Ps great idea - will use this for sure!

0

精彩评论

暂无评论...
验证码 换一张
取 消