Skip to content

Instantly share code, notes, and snippets.

@jlumpe jlumpe/pp_export.js
Created May 13, 2019

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
You can’t perform that action at this time.