PageSourceSearch

https://acrobat-project.eu/modules/contrib/spamspan/js/spamspan.js?v=10.6.9

js acrobat-project.eu collected 2026-10-04 13:25:10 UTC 2,727 bytes, 76 lines download raw bytes

1((Drupal, $) => {
2  // Load SpamSpan.
3  Drupal.behaviors.spamspan = {
4    attach: (context) => {
5      // Get each span with class spamspan.
6      $("span.spamspan", context).each(function () {
7        // Replace each <span class='o'></span> with .
8        if ($("span.o", this).length) {
9          $("span.o", this).replaceWith(".");
10        }
11
12        // For each selected span, set mail to the relevant value, removing
13        // spaces.
14        const _mail = `${$("span.u", this).text()}@${$(
15          "span.d",
16          this
17        ).text()}`.replace(/\s+/g, "");
18
19        // Build the mailto URI.
20        let _mailto = `mailto:${_mail}`;
21        if ($("span.h", this).length) {
22          // Find the header text, and remove the round brackets from the start
23          // and end.
24          const _headerText = $("span.h", this)
25            .text()
26            .replace(/^ ?\((.*)\) ?$/, "$1");
27          const _headers = $.map(_headerText.split(/, /), (n) =>
28            n.replace(/: /, "=")
29          );
30
31          const _headerString = _headers.join("&");
32          if (_headerString) {
33            _mailto += `?${_headerString}`;
34          }
35        }
36
37        // Find the anchor content, and remove the round brackets from the
38        // start and end.
39        let _anchorContent = $("span.t", this).html();
40        if (_anchorContent) {
41          _anchorContent = _anchorContent.replace(/^ ?\(([^]*)\) ?$/, "$1");
42          // Find obfuscated emails in the anchor text and normalize it.
43          _anchorContent = _anchorContent.replaceAll("[at]", "@").replaceAll("[dot]", ".");
44        }
45
46        // Check if the "span.spamspan" holds any extra attributes from the
47        // original <a> tag and put them back after removing 'data-spamspan-'
48        // string from the beginning.
49        let _attributes = '';
50        $.each(this.attributes, function () {
51          if (this.specified && this.name.startsWith("data-spamspan-")) {
52            // Sanitize the attribute value.
53            const sanitizedValue = Drupal.checkPlain(this.value);
54            _attributes += `${this.name.substring("data-spamspan-".length)}="${sanitizedValue}" `;
55          }
56        });
57        // Construct the <a> tag with the extra attributes, if there is any.
58        let _tag = "<a></a>";
59        if (_attributes) {
60          // Remove any 'on' event attributes.
61          _attributes = _attributes.replace(/on\w+=".*?"/g, '');
62          _tag = `<a ${_attributes}></a>`;
63        }
64
65        $(this)
66          .after(
67            $(_tag)
68              .attr("href", _mailto)
69              .html(_anchorContent || _mail)
70              .addClass("spamspan")
71          )
72          .remove();
73      });
74    },
75  };
76})(Drupal, jQuery);

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.