Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oumu/0afb49ccd74ecf28c47b8e1dc4c321ec to your computer and use it in GitHub Desktop.
Save oumu/0afb49ccd74ecf28c47b8e1dc4c321ec to your computer and use it in GitHub Desktop.
Migrating V2EX's starred topics to Pinboard
//
// This scripts helps you migrating V2EX's starred topics to Pinboard
// https://www.v2ex.com/t/137169
//
// 0. Edit authToken variable below.
// 1. Navigate to https://www.v2ex.com/my/topics
// 2. Paste code into browser console, and enter to execute
// 3. You should see the console scroll over some outputs
// 4. Wait for the "DONE :)" message
// 5. Move to the next page, and continue step 1
//
// Head over to https://pinboard.in/api for more parameters.
//
// Get your Auth Token from: https://pinboard.in/settings/password
var authToken = "username:random-token";
// Tags may be separated by comma? (untested)
var tags = "v2ex";
var index = 0;
function add(url) {
var img = new Image();
img.src = url;
}
$(".item_title a").each(function() {
var url = "https://api.pinboard.in/v1/posts/add?auth_token=" + authToken + "&tags=" + tags + "&url=https://www.v2ex.com" + $(this).attr("href").split("#")[0] + "&description=" + $(this).text();
// Timeout 4000 cuz Pinboard have rate limit of 3s per request
setTimeout(function() { add(url) }, index++ * 4000);
})
setTimeout(function() { alert("DONE :)"); }, index * 4000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment