(Translated by https://www.hiragana.jp/)
expand screen methods · Issue #29 · arkenfox/TZP · GitHub
Skip to content
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

Open
2 of 13 tasks
Thorin-Oakenpants opened this issue Jan 11, 2021 · 6 comments
Open
2 of 13 tasks

expand screen methods #29

Thorin-Oakenpants opened this issue Jan 11, 2021 · 6 comments
Assignees
Labels

Comments

@Thorin-Oakenpants
Copy link
Contributor

Thorin-Oakenpants commented Jan 11, 2021

reminder

  • use available screen, not screen .. in FP metrics, as available has more entropy
    • n/a : the loose fingerprint collects everything and anything it wants

items: extra conversation at abrahamjuliot/creepjs#97

@Thorin-Oakenpants
Copy link
Contributor Author

assigning @abrahamjuliot 🤣 🤣 🤣

@Thorin-Oakenpants
Copy link
Contributor Author

Thorin-Oakenpants commented Jan 27, 2021

just a random idea

  • using JS to generate css @media rules, e.g. min-device-width and min-device-height
  • width would set background color
  • height would set color
  • use the width/height to determine the color value
    • e.g. width 500 = rgb(5,0,0), 2560 = rgb(25,6,0)
  • apply to a div
  • this would only have to happen once

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

@Thorin-Oakenpants
Copy link
Contributor Author

Thorin-Oakenpants commented Apr 11, 2021

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

@Thorin-Oakenpants
Copy link
Contributor Author

^ actually, some items might return "none", which after stripping quotes marks fail, so instead use some unique string

#cssH:after{content:"not supported";}
@media (hover:none){#cssH:after{content:"none";}}
@media (hover:hover){#cssH:after{content:"hover";}}

@Thorin-Oakenpants
Copy link
Contributor Author

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)

@abrahamjuliot

@abrahamjuliot
Copy link
Collaborator

As far as I know, these values indicate x and y scroll positions.

  • if a user scrolls down, pageTop will measure the viewport distance from the top of the page
  • if a user shrinks the viewport and causes the x-axis to overflow, scrolling to the right will cause pageLeft to measure the scroll distance. offsetLeft is affected too, but I'm not sure what it's measuring.
  • really not sure how to affect offsetTop, but all this seems tied to the layout flow and positioning, and the scroll positions.
offsetLeft: 0.01666259765625
offsetTop: 0
pageLeft: 286.01666259765625
pageTop: 1020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants