Skip to content

Instantly share code, notes, and snippets.

@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 / facebook_display_load_all.js
Last active May 13, 2021 15:10
Display and load all Facebook posts / comments
/* This script will allow you to use the Ctrl+F search function of your web browser to search text in all posts / comments
* (without sending your search requests to Facebook and the HTML page can be saved with Ctrl+S as a backup for offline use).
* It is also useful if you want to save the content of a Facebook group that requires you to renew a paid membership to remain a member
* (video / audio / image and other files should be downloaded separately) */
// replace with your language translation if needed (case-sensitive)
var moreCommentText = "^View 1 more comment$"; // if the text is only "comment", script will click on unintended links containing the word "comment" in the page title
var moreCommentsText = "^View [0-9]+ more comments$";
var previousCommentsText = "^View previous comments$";
var moreReplyText = "^View 1 more reply$";
@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"));
}
@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 / facebook_friends_people_search_backup.js
Last active October 4, 2022 11:58
Facebook friends / people search / group members backup in web browser
/* Facebook friends / people search / group members backup in web browser
* Scroll down to your friends page or a people search page to load all profiles
* Copy-paste the script below in a web browser console (F12 key or Ctrl+Shift+K shortcut in a browser like Firefox) and execute the desired function, for example by typing FacebookFriendsBackup() in the console and pressing enter
* A textarea will appear at the end of the page so you can copy the data and paste it in a text file before saving it as a CSV file
* 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 removed you from their friends list or who appeared in a new search (e.g. with the Linux diff command or awk for column diff https://unix.stackexchange.com/questions/174599/using-diff-on-a-specific-column-in-a-file/174603#174603)
* If the friend changed their name or profile URL, you can still find them with their profile ID which is backed up in the last colu
@baptx
baptx / instagram-api_send_message.js
Last active December 3, 2023 05:46
Instagram API: send direct messages from a web browser
/*
Instagram API: send direct messages from a web browser
Since April 2020, Instagram has a web version to send and read direct messages so my Instagram scripts are not longer needed and I would not recommend using them unless you really need it, to avoid being banned
(never happened to me with Instagram but WhatsApp is owned by Facebook also and they did it to users registering from an unofficial app like yowsup: https://github.com/tgalal/yowsup/commit/88b8ad9581fa22dac330ee3a05fec4e485dfa634#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5)
For browser setup, see script instagram-api_direct_messages_backup.js
Instagram web version sessionid cookie does not allow sending messages so we need to log in manually
Signature should match signed_body data (using HMAC-SHA256 with private key) but wrong signature or key may work also.
@baptx
baptx / webrtc_video_blob_record.js
Last active April 26, 2024 08:21
WebRTC and video blob record (compatible with DRM and any videos like Facebook / Instagram stories)
/* Customized code to allow WebRTC record on existing page or HTML5 video blob download (based on https://github.com/webrtc/samples/blob/409d5631f38f2bdc4dafb5275d1bc77738fbb1ba/src/content/getusermedia/record/js/main.js)
* Recording will start when executing this script and you will have to execute manually startDownload() function when needed in web console with or without stopRecording()
* Recording should ideally start before playing video manually and in case controls are hidden, you can record from the start with a command like document.getElementsByTagName("video")[0].currentTime = 0
* By default, the script targets the first video element document.getElementsByTagName("video")[0] but you can change the code if needed.
*/
// If there is an error due to DRM, capture the stream by executing the following 2 lines before playing / loading the video:
var video = document.getElementsByTagName("video")[0];
var stream = video.captureStream ? video.captureStream() : video.mozCaptureStream();
@baptx
baptx / instagram-api_direct_messages_backup.js
Last active April 29, 2024 07:29
Instagram API: view and backup direct messages from a web browser
/*
Instagram API: view and backup direct messages from a web browser
Since April 2020, Instagram has a web version to send and read direct messages so my Instagram scripts are not longer needed and I would not recommend using them unless you really need it, to avoid being banned
(never happened to me with Instagram but WhatsApp is owned by Facebook also and they did it to users registering from an unofficial app like yowsup: https://github.com/tgalal/yowsup/commit/88b8ad9581fa22dac330ee3a05fec4e485dfa634#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5)
1) Log in on Instagram web version and go to your profile page
(the home page will not work because it loads data when scrolling down and the direct messages will be displayed at the bottom of the page)
2) Modify HTTP headers with a browser addon like Header Editor (https://addons.mozilla.org/en-US/firefox/addon/header-editor/)