Skip to content

Instantly share code, notes, and snippets.

@danburzo
Last active August 30, 2023 06:52
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save danburzo/dbb815651623020c1f5f to your computer and use it in GitHub Desktop.
Save danburzo/dbb815651623020c1f5f to your computer and use it in GitHub Desktop.
Scrape your Facebook saved links

Facebook does not provide an easy way to get your saved links out of its system. Here's a quick script that does that for you.

Instructions

Go to your Saved links page and make sure you scroll way down to the bottom so that all your saved items are loaded. This script will generate a simple HTML page with your links, along with an Add to Pinboard action.

Bookmarklet

Drag this to your bookmarks toolbar: Facebook Saved Links

@akaralar
Copy link

It doesn't work for me in Safari, any hints?

@akaralar
Copy link

akaralar commented Nov 21, 2018

this is the address the bookmarklet is pointing to: javascript:eval(unescape("//%20selector%20for%20accessing%20the%20links%0A//%20%28this%20might%20be%20subject%20to%20change%29%0Avar%20ITEM_SELECTOR%20%3D%20%22._4bl9%20%3E%20a%3Afirst-child%22%3B%0A%0Avar%20elements%20%3D%20%5B%5D.slice.call%28document.querySelectorAll%28ITEM_SELECTOR%29%29%3B%0A%0Avar%20items%20%3D%20elements.map%28function%28element%29%20%7B%20%0A%09%0A%09var%20title%20%3D%20element.textContent.trim%28%29%3B%0A%09var%20href%20%3D%20element.getAttribute%28%27href%27%29%3B%20%0A%0A%09//%20clean%20up%20weird%20links%0A%09if%20%28href.indexOf%28%27l.php%27%29%20%3E%20-1%29%20%7B%20%0A%09%09//%20remove%20facebook%20proxy%20l.php%3Fu%3D%3Curl%3E%0A%09%09href%20%3D%20decodeURIComponent%28href.match%28/u%3D%28%5B%5E%5C%26%5D+%29/%29%5B1%5D%29%3B%0A%09%7D%20else%20if%20%28href.indexOf%28%27http%27%29%20%21%3D%3D%200%29%20%7B%0A%09%09//%20make%20relative%20links%20absolute%0A%09%09href%20%3D%20%27https%3A//facebook.com%27%20+%20href%3B%20%0A%09%7D%0A%09%0A%09return%20%7B%0A%09%09title%3A%20title%2C%0A%09%09href%3A%20href%2C%0A%09%09pinboard_url%3A%20%60https%3A//pinboard.in/add%3Furl%3D%24%7BencodeURIComponent%28href%29%7D%26title%3D%24%7BencodeURIComponent%28title%29%7D%60%0A%09%7D%0A%7D%29%3B%0A%0Avar%20content%20%3D%20items.map%28function%28item%29%20%7B%0A%09return%20%60%0A%09%3Cli%3E%0A%09%09%3Ca%20href%3D%27%24%7Bitem.href%7D%27%20target%3D%27_blank%27%3E%24%7Bitem.title%7D%3C/a%3E%20%u30FB%20%0A%09%09Add%20to%3A%20%3Ca%20href%3D%27%24%7Bitem.pinboard_url%7D%27%20target%3D%27_blank%27%3EPinboard%3C/a%3E%0A%09%3C/li%3E%60%3B%0A%7D%29.join%28%27%5Cn%27%29%3B%0A%0Avar%20output%20%3D%20%60%3C%21doctype%20html%3E%0A%3Chtml%3E%0A%09%3Chead%3E%0A%09%09%3Cmeta%20charset%3D%22utf-8%22%3E%0A%09%09%3Ctitle%3EFacebook%20Saved%20Links%3C/title%3E%0A%09%3C/head%3E%0A%09%3Cbody%3E%0A%09%09%3Ch1%3EFacebook%20Saved%20Links%3C/h1%3E%0A%09%09%3Cul%3E%0A%09%09%09%24%7Bcontent%7D%0A%09%09%3C/ul%3E%0A%09%3C/body%3E%0A%3C/html%3E%60%3B%0A%0Avar%20result_url%20%3D%20URL.createObjectURL%28new%20Blob%28%5Boutput%5D%2C%20%7Btype%3A%20%27text/html%27%20%7D%29%29%3B%0Awindow.location%20%3D%20result_url%3B"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment