GithubHelp home page GithubHelp logo

xandermann / html-classes-obfuscator Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 1.0 56 KB

Obfuscate class names in HTML, CSS and Javascript files.

Home Page: https://pypi.org/project/html-classes-obfuscator/

License: MIT License

Python 86.06% HTML 7.06% JavaScript 2.32% CSS 4.56%

html-classes-obfuscator's Introduction

html-classes-obfuscator's People

Contributors

biasedkiwi avatar deepsourcebot avatar xandermann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

biasedkiwi

html-classes-obfuscator's Issues

Not working if class name begins with a number

A class name should not begin with a number:

https://www.w3.org/TR/CSS21/syndata.html#characters

In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier “B&W?” may be written as “B&W?” or “B\26 W\3F”.

Should we add a warning in the README ?

Class names in variables aren't replaced in JS

Describe the bug
Class names in variables aren't replaced in Javascript

To Reproduce

const cl = ".my_class_name"
document.querySelector(cl); // Not working

// ---

const cl = ".my_class" + "_name"
document.querySelector(cl); // Not working

// ---

const id = "#my_class_id"
document.querySelector(id); // Not working

Expected behavior
It should replace the variable content

Javascript classes not replaced when using single quotes

# TODO
# def test_generate_js_query_selector_simple_quotes(self) -> None:
# """Test"""
# new_js = html_classes_obfuscator.generate_js("document.querySelector('.hello')", {"hello": "test_1"})
# expected_new_js = 'document.querySelector(".test_1")'
# self.assertEqual(new_js, expected_new_js)

# TODO
# def test_generate_js_query_selector_all_simple_quotes(self) -> None:
# """Test"""
# new_js = html_classes_obfuscator.generate_js("document.querySelectorAll('.hello')", {"hello": "test_1"})
# expected_new_js = "document.querySelectorAll('.test_1')"
# self.assertEqual(new_js, expected_new_js)

# TODO
# def test_generate_js_toggle_class_list_simple_quotes(self) -> None:
# """Test"""
# new_js = html_classes_obfuscator.generate_js("myDiv.classList.toggle('hello')", {"hello": "test_1"})
# expected_new_js = "myDiv.classList.toggle('test_1')"
# self.assertEqual(new_js, expected_new_js)

Add support for AlpineJS

Is your feature request related to a problem? Please describe.

<div
    x-bind:class="title === 0 && 'bg-gray-100 text-gray-900'"
></div>

Describe the solution you'd like
Minify the classes bg-gray-100 text-gray-900 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.