This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(', '); |