Skip to content

Instantly share code, notes, and snippets.

Avatar

josh-meinders

View GitHub Profile
@josh-meinders
josh-meinders / parseFacebookFriendPage.js
Last active Jun 27, 2020
Parse profile id, vanity, and name from Facebook friends page. Make sure you scroll to bottom first!
View parseFacebookFriendPage.js
function parse() {
let people = document.querySelectorAll("._5qo4");
for (let i = 0; i < people.length; i++) {
const aElement = people[i].querySelector("a._5q6s");
let id = null;
let vanity = null;
if (aElement != null) {
const hovercardLink = aElement.getAttribute("data-hovercard");
const idRegex = new RegExp("^/ajax/hovercard/user.php\\?id=(\\d{1,})&.{1,}", "g");
id = idRegex.exec(hovercardLink)[1];
@josh-meinders
josh-meinders / parseFacebookBirthdaysPage.js
Last active Jun 27, 2020
Parse profile link, birthday month, and birthday day from Facebook birthdays page. Make sure you scroll to bottom first!
View parseFacebookBirthdaysPage.js
function parse() {
let people = document.querySelectorAll("._43q7");
for (let i = 0; i < people.length; i++) {
const profile = people[i].childNodes[0].href
const tooltip = people[i].childNodes[0].getAttribute("data-tooltip-content");
const monthRegex = new RegExp("\\((\\d{1,2})/\\d{1,2}\\)$", "g");
const dayRegex = new RegExp("\\(\\d{1,2}/(\\d{1,2})\\)$", "g");
const monthMatch = monthRegex.exec(tooltip);
const dayMatch = dayRegex.exec(tooltip);
const month = monthMatch == null ? null : monthMatch[1];
@josh-meinders
josh-meinders / addFormResponseIdAndUrl.gs
Created Apr 10, 2020
On Google Form submission, append the response id and edit response link to the Google Sheet row. Supports rapid form submissions. #google-apps-script #forms
View addFormResponseIdAndUrl.gs
function createFormTrigger() {
var triggerFunctionName = "addFormResponseIdAndUrl_";
deleteAllExistingTriggers_();
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
ScriptApp.newTrigger(triggerFunctionName)
.forSpreadsheet(spreadsheet)
.onFormSubmit()
.create();
}
@josh-meinders
josh-meinders / splitRangeIntoRows.gs
Last active Apr 10, 2020
Split range into an array of ranges representing the rows of the original range #google-apps-script #range
View splitRangeIntoRows.gs
function splitRangeIntoRows(range) {
const sheet = range.getSheet();
const firstRow = range.getRow();
const lastRow = firstRow + range.getNumRows() - 1;
let rows = [];
for (let rowIndex = firstRow; rowIndex <= lastRow; rowIndex++) {
rows.push(sheet.getRange(`${rowIndex}:${rowIndex}`));
}
return rows;
}
You can’t perform that action at this time.