Skip to content

Instantly share code, notes, and snippets.

@gaomd
Last active October 28, 2023 09:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gaomd/7da5de92561dbd0c6b44 to your computer and use it in GitHub Desktop.
Save gaomd/7da5de92561dbd0c6b44 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