CSS Injector
CSS injector with regex functionality
CSS Injector features:
CSS Injector can be used importing the JS code via CDN
<script src="https://cdn.jsdelivr.net/npm/@mobiloud/ml-css-injector@latest/dist/ml-css-injector.min.js"></script>
<script>
(function(){
addStyle({css: `a{color: red !important}`});
addStyle({css: `a{color: yellow !important}`, regex: /\/\?param$/});
addStyle({css: `a{color: green !important}`, regex: /.*/, name: "Global Styles"});
addStyle({css: `a{color: green !important}`, regex: /.*/, name: "Global Styles", logs: true});
})()
</script>
// accepts any styles as a string
let style = `
a{
color: green;
background-color: yellow
}
.className {
font-size: 2rem
}
`
// accepts regex enclosed within slashes
let regex = /.*/
// accepts string
let name = "Style name"
//boolean --> Prints logs in console for debugging
addStyle({css: string, regex: string, name: string, logs: boolean});
addStyle({css: `color: red !important`}) // if no regex passed, the styles applies to every page
// accepts any styles as a string
let styles = [
{
css: `
a{
color: green;
background-color: yellow
}
`,
regex: /.*/,
name: "Global Styles"
},
{
css: `
.cart{
color: green;
background-color: yellow
}
`,
regex: /.*\/cart/,
name: "Cart page"
},
{
css: "div.login{display: none}",
regex: /.*\/login/,
name: "Login page"
}
]
// accepts regex enclosed within slashes
styles.forEach(e => {
addStyle({
css: e.css,
regex: e.regex,
name: e.name,
logs: true
})
} )
deviceData.os // returns current os "android" | "ios" | "windows" | "desktop"
deviceData.isCanvas // returns true or false
deviceData.isMobile // returns true or false