Skip to content

Instantly share code, notes, and snippets.

@jlumpe
Created May 13, 2019 22:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Tampermonkey script for fast BibTeX export in Paperpile app
// ==UserScript==
// @name Paperpile BibTeX export button
// @version 0.1
// @author Jared Lumpe
// @match http*://paperpile.com/app
// @grant unsafeWindow
// ==/UserScript==
(function() {
'use strict';
function exportBibtex()
{
console.log('Triggering hacky PP export');
unsafeWindow.Ext.create("Paperpile.view.settings.ExportView", {format: "BibTeX"}).triggerExport();
}
function injectButton()
{
var toolbarSpace = document.querySelector('.pp-top-toolbar [id^="tbfill"]');
if (toolbarSpace == undefined)
{
console.error("Couldn't find element to insert export button");
return;
}
var btnContainer = document.createElement('DIV');
btnContainer.style.cssText = 'float: right; transform: translate(0, -50%);';
var btn = document.createElement('BUTTON')
btn.innerHTML = 'Export BibTeX';
btn.onclick = exportBibtex;
btnContainer.appendChild(btn);
toolbarSpace.appendChild(btnContainer);
return btn;
}
window.onload = function() {
setTimeout(function() {
console.log('Injecting PP export button');
injectButton();
},
2000);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment