Marti / GM_setStyle

Here is a way to apply CSS style per element.

This is useful in case Subresource Integrity is enabled.

I might be missing here something or it is impossible to utilize pseudo-class in the fashion persented here.

Please pardon me for the mess (i.e. slice & replace).

jsonStyle = {
  // CSS stylesheet converted into JSON
}

list = Object.keys(jsonStyle);

for (let i = 0; i < list.length; i++) {
  for (const element of document.querySelectorAll(`${list[i]}`)) {
    element.style = JSON.stringify(jsonStyle[`${list[i]}`])
      .slice(2)
      .replace('"}','')
      .replace(/['"]+/g, '')
      .replace(/[',]+/g, ';');
    //console.log(list[i])
    //console.log(element.style)
  }
}

I've used this tool to convert CSS to JSON https://transform.tools/css-to-js

Why was this closed?

Don't you think this is worth attention, especially when it is concerning to Userscripts and the news SRI policy?

What would be the best place to collaborate on this suggestion if not here?