Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name Roam YouTube timestamp controls
// @namespace learnstream.org
// @version 0.1
// @description Add timestamp controls to YouTube videos embedded in Roam
// @author Ryan Muller <[email protected]>
// @match https://*.roamresearch.com
// @grant none
// ==/UserScript==
// Copyright 2020 Google LLC.
@ryanmuller
ryanmuller / content.js
Created December 4, 2020 19:29
scrape google scholar for roam as chrome extension
chrome.runtime.onMessage.addListener(function(msg, sender, callback) {
let title, year, journal, url;
let authors = [];
const citationRows = document.getElementById('gs_citt').getElementsByTagName('tr');
for (let i = 0; i < citationRows.length; i++) {
if (citationRows[i].getElementsByTagName('th')[0].textContent === 'Chicago') {
const chicagoCitation = citationRows[i].getElementsByTagName('td')[1].textContent;
// TODO: improve year match
const matches = chicagoCitation.match(/^(.*)\.\ "(.*)\."\ (?:In\ )?([^,]*).*\b(\d\d\d\d)\b/);
const authorParts = matches[1].split(', ');