You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
angularjs-batarang/app/devtools-panel/js/services/appCss.js

24 lines
863 B
JavaScript

// Service for injecting CSS into the application
angular.module('panelApp').factory('appCss', function (chromeExtension) {
return {
addCssRule: function (args) {
chromeExtension.eval(function (window, args) {
var styleSheet = document.styleSheets[document.styleSheets.length - 1];
styleSheet.insertRule(args.selector + '{' + args.style + '}', styleSheet.cssRules.length);
}, args);
},
removeCssRule: function (args) {
chromeExtension.eval(function (window, args) {
var styleSheet = document.styleSheets[document.styleSheets.length - 1];
var i;
for (i = styleSheet.cssRules.length - 1; i >= 0; i -= 1) {
if (styleSheet.cssRules[i].cssText === args.selector + ' { ' + args.style + '; }') {
styleSheet.deleteRule(i);
}
}
}, args);
}
};
});