PageSourceSearch

https://www.fuelcellshop.com/front/_heliocentrisacademia/node_modu…/obfuscator/assets/jquery.obfuscator.js

js fuelcellshop.com collected 2026-10-04 21:37:43 UTC 6,413 bytes, 156 lines download raw bytes

1/*
2 * jQuery Obfuscator plugin
3 *
4 * Autor původního kódu: Jan OndrouÅ¡ek <[email protected]>
5 * Refactor do jQuery pluginu: Michal Kvita <[email protected]>
6 */
7;
8(function ($, window, document) {
9
10    var pluginName = 'obfuscator',
11        defaults = {
12            code: '1234567890',
13            obfusSelector: '.obfus-container',
14            // direct|click|focus
15            decodeMailtoPolicy: 'direct',
16        };
17
18    function Obfuscator(options) {
19        this.options = $.extend({}, defaults, options);
20        this._defaults = defaults;
21        this._name = pluginName;
22        this.options.code = this.options.code.toString();
23    }
24
25    Obfuscator.prototype = {
26        obfusPrefix: '[obfuscate_',
27        obfusSuffix: ']',
28        obfusSplit: '|',
29        //
30        typeMail: 1,
31        typeTag: 2,
32        typeMailto: 3,
33        //
34        obfusParameterProcessed: 'data-obfus-processed',
35
36        /**
37         *
38         * @param {string|object} element HTML string nebo jQuery DOM objekt, document jako výchozí
39         * @returns {string|object}
40         */
41        process: function (element = null) {
42            var self = this;
43
44            var elementIsString = typeof element === 'string';
45            if (element === null) {
46                element = $(document);
47            } else {
48                element = $(element);
49            }
50
51            element.find(self.options.obfusSelector + ':not(' + self.obfusParameterProcessed + ')').each(function () {
52                $(this).html(self.parseObfuscated($(this).html()));
53
54                // Umožní vykopírování celé adresy po označení (včetně @)
55                var obfusFirstEl = $(this).find('obfus-first').get(0);
56                var obfusFirstElContent = window.getComputedStyle(obfusFirstEl, ":after").content;
57                if (["attr(content)", "'@'", '"@"', '@'].indexOf(obfusFirstElContent) >= 0 && obfusFirstEl.getAttribute("content") != "") {
58                    obfusFirstEl.setAttribute("content", "");
59                    obfusFirstEl.innerHTML += "@";
60                }
61
62                $(this).attr(self.obfusParameterProcessed, '1').show();
63            });
64
65            element.find('a[href^="mailto:"]:not(' + self.obfusParameterProcessed + ')').each(function () {
66                // V případě předání stringu se e-maily rovnou de-obfuskují
67                var decodeMailtoPolicy = self.options.decodeMailtoPolicy;
68                if (elementIsString) {
69                    decodeMailtoPolicy = 'direct';
70                }
71
72                var parseMailtoObfuscated = function (href) {
73                    return 'mailto:' + self.parseObfuscated(href.replace('mailto:', ''));
74                };
75
76                if (decodeMailtoPolicy === 'click') {
77                    // Politika de-obfuskování při kliku na odkaz
78                    $(this).on('click', function (e) {
79                        e.preventDefault();
80                        window.location.href = parseMailtoObfuscated($(this).attr('href'));
81                    });
82                } else if (decodeMailtoPolicy === 'focus') {
83                    // Politika de-obfuskování při najetí/výběru prvku odkazu
84                    $(this).on('focusin mouseenter click', function (e) {
85                        $(this).attr('href', parseMailtoObfuscated($(this).attr('href')));
86                    });
87                } else {
88                    $(this).attr('href', parseMailtoObfuscated($(this).attr('href')));
89                }
90
91                $(this).attr(self.obfusParameterProcessed, '1');
92            });
93
94            return elementIsString ? element.prop('outerHTML') : element;
95        },
96
97        /**
98         * Zpracuje obfuskovaný vstup - výsledný tvar vrací podle detekovaného typu uvnitř obfsukovaného řetězce
99         *
100         * @param {string} obfuscated
101         * @returns {string}
102         */
103        parseObfuscated: function (obfuscated) {
104            // Jiz bylo zpracovano
105            var pattern_base = new RegExp('\\' + this.obfusPrefix);
106            if (!pattern_base.test(obfuscated)) {
107                return obfuscated;
108            }
109
110            var pattern_mail = new RegExp('\\' + this.obfusPrefix + this.typeMail + '_
110([0-9' + this.obfusSplit + ']*)\\]');
111            var pattern_mailto = new RegExp('\\' + this.obfusPrefix + this.typeMailto + '_([0-9' + this.obfusSplit + ']*)\\]');
112
113            if (pattern_mail.test(obfuscated)) { // obfuscated v plaintextu
114                obfuscated = obfuscated.replace(this.obfusPrefix + this.typeMail + "_" + this.obfusSplit, "");
115                obfuscated = obfuscated.replace(this.obfusSuffix, "");
116                obfuscated = obfuscated.split(this.obfusSplit);
117                obfuscated = this.decode(obfuscated);
118                return "<obfus-first content=\"@\">" + obfuscated.replace("@", "</obfus-first><obfus-second>") + "</obfus-second>";
119            } else if (pattern_mailto.test(obfuscated)) { // obfuscated v mailto:
120                obfuscated = obfuscated.replace(this.obfusPrefix + this.typeMailto + "_" + this.obfusSplit, "");
121                obfuscated = obfuscated.replace(this.obfusSuffix, "");
122                obfuscated = obfuscated.split(this.obfusSplit);
123                obfuscated = this.decode(obfuscated);
124                return obfuscated;
125            } else { // obfuscated v tagu
126                obfuscated = obfuscated.replace(this.obfusPrefix + this.typeTag + "_" + this.obfusSplit, "");
127                obfuscated = obfuscated.replace(this.obfusSuffix, "");
128                obfuscated = obfuscated.split(this.obfusSplit);
129                obfuscated = this.decode(obfuscated);
130                return obfuscated;
131            }
132        },
133
134        /**
135         * Dekódování obfuskovaného e-mailu
136         *
137         * @param {string} email
138         * @returns {string}
139         */
140        decode: function (email) {
141            var result = "";
142            for (var i = 0; i < email.length; i++)
143            { // zvysi ASCII hodnotu znaku o odpovidajici hodnotu v kodu
144                result += String.fromCharCode(parseInt(email[i]) + parseInt(this.options.code.charAt(i % this.options.code.length)));
145            }
146
147            return result;
148        },
149
150    };
151
152    $.fn[pluginName] = function (options) {
153        return new Obfuscator(options);
154    };
155
156})(jQuery, window, document);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.