-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expand screen methods #29
Comments
assigning @abrahamjuliot 🤣 🤣 🤣 |
just a random idea
Read the div's colors back to return the width/height. i.e a JS approach to read back pure css (which extensions can't alter?) function evil_bastard(styleType, styleMin, styleMax) {
// styleType: e.g. inner, outer, screen, availablescreen
//loop, create styles
styles = [] // not sure if array is the way to go
for (let i=styleMin; i < (styleMax + 1); i++) {
//build rules and add to styles
}
var styleSheet = document.createElement("style")
styleSheet.type = "text/css"
styleSheet.innerText = styles
document.head.appendChild(styleSheet)
// apply class to element
}
evil_bastard(screen, 300, 2560) // promise it and then check the element's colors? edit: perf: it could also be used to simply check the reported screen/window values, as compared to unmasking the real values |
actually .. I already have the css rules, and can just use the after pseudo element #cssPCS:after{content:"not supported"}
@media (prefers-color-scheme:light){#cssPCS:after{content:"light";}}
@media (prefers-color-scheme:dark){#cssPCS:after{content:"dark";}}
@media (prefers-color-scheme:no-preference){#cssPCS:after{content:"no-preference";}} /* obsolete FF79+: 1643656 */ edit: updated version function getElementProp(id, prop, pseudo) {
try {
let item = window.getComputedStyle(document.querySelector(id), pseudo)
item = item.getPropertyValue(prop)
if (item == "none") {item = "x"; console.warn(id, item)}
item = item.replace(/"/g,"")
if (!isNaN(item * 1)) {item = item * 1} // return numbers as numbers
item = (item == "" ? "x" : item) // handle blanks as invalid
return item
} catch(e) {
console.error(id, e.name, e.message)
return "x"
}
} Since some extensions block matchMedia (e.g. Cydec), I now use this as the real value example // snip: mmValue = window.matchMedia .. etc
let cssValue = getElementProp("#cssPCS","content",":after")
if (cssValue !== "none" ) {mmValue = cssValue} // update with real value, record lie, etc Of course the wee media.css file (26k) I can move up to the header, but not sure about 500kb of screen.css + window.css - but something to think about |
^ actually, some items might return #cssH:after{content:"not supported";}
@media (hover:none){#cssH:after{content:"none";}}
@media (hover:hover){#cssH:after{content:"hover";}} |
what is the point of offset and page? they're zero's I don't follow, can you apply them to an element of something? (which could come in handy in some element tests down the track) |
As far as I know, these values indicate x and y scroll positions.
|
reminder
items: extra conversation at abrahamjuliot/creepjs#97
getComputedStyle
: https://jsfiddle.net/jrnca3wh/@media
: https://jsfiddle.net/w8qxu1p2/1/@import
can access media queries: https://jsfiddle.net/873kspn4/1/The text was updated successfully, but these errors were encountered: