mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 17:23:37 +00:00
remove inline fallback code for CSP
This commit is contained in:
9
src/js/fallback-scripts.js
Normal file
9
src/js/fallback-scripts.js
Normal file
@@ -0,0 +1,9 @@
|
||||
function loadScriptIfMissing(condition, path) {
|
||||
if (!condition) {
|
||||
document.write('<script src="' + path + '?v=' + cacheTag + '"><\/script>');
|
||||
}
|
||||
}
|
||||
|
||||
loadScriptIfMissing(window.jQuery, 'lib\/jquery\/jquery.min.js');
|
||||
loadScriptIfMissing(window.jQuery && window.jQuery.fn && window.jQuery.fn.modal, 'lib\/bootstrap\/js\/bootstrap.min.js');
|
||||
loadScriptIfMissing(window.angular, 'lib\/angular\/angular.min.js');
|
||||
17
src/js/fallback-styles.js
Normal file
17
src/js/fallback-styles.js
Normal file
@@ -0,0 +1,17 @@
|
||||
var cacheTag = '/* @echo cacheTag */' || '';
|
||||
|
||||
function loadStylesheetIfMissing(property, value, paths) {
|
||||
var scripts = document.getElementsByTagName('SCRIPT'),
|
||||
siblings = scripts[scripts.length - 1].previousElementSibling,
|
||||
meta = document.defaultView && document.defaultView.getComputedStyle ?
|
||||
document.defaultView.getComputedStyle(siblings) : siblings.currentStyle;
|
||||
|
||||
if (meta && meta[property] !== value) {
|
||||
for (var i = 0; i < paths.length; i++) {
|
||||
document.write('<link rel="stylesheet" href="' + paths[i] + '?v=' + cacheTag + '" />');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loadStylesheetIfMissing('visibility', 'hidden', ['lib\/bootstrap\/css\/bootstrap.min.css']);
|
||||
loadStylesheetIfMissing('fontFamily', 'FontAwesome', ['lib\/font-awesome\/css\/font-awesome.min.css']);
|
||||
Reference in New Issue
Block a user