Skip to content

pokemonish/strict_dom.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

strict_dom.js

Removing desired tags and attributes from your site (watch example here) using MutationObserver

Usage:

Here are 3 examples of strict_dom configuration:

using emembed manifest: putting manifest in script tag as JSON

<script src="strict_dom.js">
{
    "tagsType": "blacklist",
    "tags": [
        "script"
    ],
    "attributesType": "blacklist",
    "attributes": {
        "*": ["onerror"]
    }
}
</script>

emembed manifest by id: putting manifest in any tag by given id as JSON

<noscript id="some_id">
{
    "tagsType": "blacklist",
    "tags": [
        "script"
    ],
    "attributesType": "blacklist",
    "attributes": {
        "*": ["onerror"]
    }
}
</noscript>
<script src="strict_dom.js" manifest="some_id"></script>

setting global manifest: saving manifest value in window.strictDomManifest variable

<script>
window.strictDomManifest = {
    "tagsType": "blacklist",
    "tags": [
        "script"
    ],
    "attributesType": "blacklist",
    "attributes": {
        "*": ["onerror"]
    }
}
</script>
<script src="strict_dom.js"></script>

Important: manifest must be declared before script import

Manifest structure:

  • outdatedUrl (String): URL which will be navigated if browser doesn't suppot MutationObserver (default: no URL)
  • tagsType (String): "blacklist" (remove tags mentioned in tags) or "whitelist" (remove all tags except mentioned in tags)
  • tags (Array of strings): names of tags
  • attributesType (String): "blacklist" (remove tags mentioned in attributes) or "whitelist" (remove all tags except mentioned in attributes)
  • attributes (Object of Arrays of Strings): name of attributes (star means any tag)

About

Removing desired tags from your site

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published