Skip to content

Instantly share code, notes, and snippets.

@dimidd
Created August 14, 2021 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimidd/45769dc156a92af9fce525ad7a6d89a6 to your computer and use it in GitHub Desktop.
Save dimidd/45769dc156a92af9fce525ad7a6d89a6 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name cal_anchors
// @version 1
// @grant none
// @include http://cal.huc.edu/*
// ==/UserScript==
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
url = window.location.href;
prefix = url.match(/file=(\d+)/)[1];
table = document.getElementsByTagName('table')[1];
trs = table.children[0].children;
for (let r of trs) {
bdo = r.getElementsByTagName('bdo')[0];
naiveReverse = function(string) {
return string.split('').reverse().join('');
};
suffix = naiveReverse(bdo.innerText).replace(/[\s.:\(\)]/g, '');
r.id = prefix + suffix;
}
row = urlParams.get('row');
console.log(row);
document.getElementById(row).scrollIntoView();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment