Skip to content

Instantly share code, notes, and snippets.

@lolobosse
Created September 14, 2020 06:34
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 lolobosse/2d0f825af0e60e905f2fcfb5c92c4d1e to your computer and use it in GitHub Desktop.
Save lolobosse/2d0f825af0e60e905f2fcfb5c92c4d1e to your computer and use it in GitHub Desktop.
// var app = chrome.runtime.getBackgroundPage();
document.addEventListener('DOMContentLoaded', function () {
debugger;
console.log("the doc loaded")
var form = document.getElementById("form")
console.log(form)
form.addEventListener('submit', function (e) {
e.preventDefault()
console.log("added to the form")
var rnr = parseInt(document.getElementById('rnr').value)
console.log(rnr);
chrome.storage.sync.set({rnr}, function () {
console.log('Has been set')
concatenateInjections(["jquery-3.5.1.min.js",
"jspdf.min.js",
"jspdf.plugin.autotable.js",
"moment-with-locales.min.js"],
'alert.js')
})
})
});
function concatenateInjections(ar, scrpt) {
var i = ar.length;
var idx = 0;
function inject(idx) {
idx++;
if (idx <= i) {
var f = ar[idx - 1];
chrome.tabs.executeScript({file: f}, function () {
inject(idx);
});
} else {
if (typeof scrpt === 'undefined') return;
chrome.tabs.executeScript({file: scrpt});
}
}
inject(idx);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment