Skip to content

Instantly share code, notes, and snippets.

@baptx
baptx / twitter_api_1.1_backup.js
Last active July 29, 2022 10:00
Twitter API 1.1 tweets / favorites (likes) / following / followers backup in web browser
/* Twitter API 1.1 tweets / favorites (likes) / following / followers backup in web browser
* Get your access keys to use Twitter API 1.1: https://dev.twitter.com/docs/auth/tokens-devtwittercom
* You can change Twitter API URL and Twitter screen_name, then execute script from a trusted web page without CSP protection like about:blank in a web browser console (F12 or Ctrl+Shift+K shortcut)
* A textarea will appear so you can copy/paste to save data as a CSV file or search tweets / users in your web browser (Ctrl+F shortcut)
* You can then view your backup in a spreadsheet editor like LibreOffice Calc
* You can also compare the backup with another one to see who unfollowed you, who changed their Twitter username by looking at the user ID or which tweet you retweeted / favorited was deleted (e.g. with the Linux diff command)
*
* Note about the tweets backup:
* Usually you will search tweets that you retweeted using Twitter web version (https://twitter.com/search) with a search like "from:your_username f
@baptx
baptx / twitter_api_1.1.js
Last active March 30, 2021 11:26
Access Twitter API 1.1 in web browser
/* Access Twitter API 1.1 in browser.
** Get your access keys to use Twitter API 1.1: https://dev.twitter.com/docs/auth/tokens-devtwittercom
** Format JSON in Firefox: https://addons.mozilla.org/EN-us/firefox/addon/jsonview/
** You can change Twitter API URL and Twitter screen_name, then execute script from a trusted web page without CSP protection like about:blank in Firefox Scratchpad or any other browser console.
*/
var script = document.createElement("script");
script.setAttribute("src", "https://pastebin.com/raw/HFjqYLdG"); // http://oauth.googlecode.com/svn/code/javascript/oauth.js (down)
document.body.appendChild(script);
@baptx
baptx / copy_folder_by_filename.sh
Created October 12, 2014 14:05
Copy folder by filename
IFS=$'\n'
if [ $# == 2 ]; then
if [ ! -d $1 ]; then
echo "Error: directory $1 does not exist"
else
dir=$1
len=$((${#dir} + 1))
if [ ! -d $2 ]; then
mkdir $2
fi
@baptx
baptx / remame_by_playlist_index.sh
Created October 12, 2014 14:02
Rename by playlist index
IFS=$'\n'
if [ $# -gt 0 ]; then
if [ ! -f $1 ]; then
echo "Error: file $1 does not exist"
exit
fi
path=`echo $1 | rev | cut -d / -f 2- | rev`
if [ $path == $1 ]; then
path=$PWD
fi
@baptx
baptx / amazon_mp3_multiple_download.user.js
Created October 12, 2014 13:56
Amazon MP3 multiple download (Amazon Cloud Player for Web)
// ==UserScript==
// @name amazon_mp3_multiple_download
// @namespace amazon
// @description Download all songs in current playlist
// @include https://www.amazon.*/gp/dmusic/mp3/player*
// @version 1
// @grant none
// ==/UserScript==
setTimeout(function() {
@baptx
baptx / twitter_timeline_update.js
Created October 12, 2014 13:46
Twitter timeline update
var target_tweet = document.getElementsByClassName("stream-container")[0];
var observer = new MutationObserver(function(mutations) {
for (var i = 0; mutations[i]; i++)
document.getElementsByClassName("new-tweets-bar")[0].click();
});
var config = { attributes: true, childList: true, characterData: true }
observer.observe(target_tweet, config);
@baptx
baptx / twitter_timeline_scroll.js
Last active August 29, 2015 14:07
Twitter timeline scroll
// Scroll Twitter home (worked for profiles too before a Twitter update)
/*var target_tweet = document.getElementById("stream-items-id");
var target_fail = document.getElementsByClassName("stream-fail-container")[0];*/
// Scroll Twitter profiles
var target_tweet = document.getElementsByClassName("GridTimeline-items")[0];
var target_fail = document.getElementsByClassName("GridTimeline-failure")[0];
var height = target_tweet.scrollHeight;
var observer = new MutationObserver(function(mutations) {
@baptx
baptx / twitter_uri_resolver.js
Created October 12, 2014 13:33
Twitter URI resolver (t.co links)
var linksLength = document.getElementsByClassName("twitter-timeline-link").length;
for (var i = 0; i < linksLength; i++) {
var link = document.getElementsByClassName("twitter-timeline-link")[i];
if (link.getAttribute("data-ultimate-url"))
link.setAttribute("href", link.getAttribute("data-ultimate-url"));
else
link.setAttribute("href", link.getAttribute("data-expanded-url"));
}