hamsket icon indicating copy to clipboard operation
hamsket copied to clipboard

Fix WhatsApp properly

Open flying-sheep opened this issue 4 years ago • 2 comments

Fixes #199 for good.

The style of the badge class is this:

._38M1B{
  display:inline-block;
  min-width:.9em;
  min-height:1em;
  font-size:12px;
  font-weight:600;
  line-height:1em;
  color:var(--unread-marker-text);
  vertical-align:top}
html[dir] ._38M1B{
  padding:.3em .4em .4em;
  text-align:center;
  background-color:var(--unread-marker-background);
  border-radius:1.1em
}
html[dir] .vc2I1{
  background-color:var(--unread-marker-background-muted)
}
.os-mac ._38M1B{
min-width:.8em;font-weight:500
}
html[dir] .os-mac ._38M1B{
  padding:.3em .4em
}

Therefore we can find the class using:

const className = Array.from(document.styleSheets)
  .flatMap(s => Array.from(s.cssRules))
  .filter(r => r instanceof CSSStyleRule)
  .find(({style}) => style.color === 'var(--unread-marker-text)')
  .selectorText.split('.').reverse()[0]

(I went for split → reverse → [0] instead of substring(1) in case they add some selector in front in the future)

flying-sheep avatar Mar 08 '21 14:03 flying-sheep

Hi @TheGoddessInari what do you think?

flying-sheep avatar Mar 27 '21 16:03 flying-sheep

So is Hamsket still being maintained or is it going the way of Rambox?

huyz avatar Nov 16 '21 11:11 huyz