-
-
Notifications
You must be signed in to change notification settings - Fork 175
Update template for yandex counter #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,25 +12,15 @@ | |||||
|
|
||||||
| COUNTER_ID_RE = re.compile(r'^\d{8}$') | ||||||
| COUNTER_CODE = """ | ||||||
| <script> | ||||||
| (function (d, w, c) { | ||||||
| (w[c] = w[c] || []).push(function() { | ||||||
| try { | ||||||
| w.yaCounter%(counter_id)s = new Ya.Metrika(%(options)s); | ||||||
| } catch(e) { } | ||||||
| }); | ||||||
|
|
||||||
| var n = d.getElementsByTagName("script")[0], | ||||||
| s = d.createElement("script"), | ||||||
| f = function () { n.parentNode.insertBefore(s, n); }; | ||||||
| s.type = "text/javascript"; | ||||||
| s.async = true; | ||||||
| s.src = "https://mc.yandex.ru/metrika/watch.js"; | ||||||
|
|
||||||
| if (w.opera == "[object Opera]") { | ||||||
| d.addEventListener("DOMContentLoaded", f, false); | ||||||
| } else { f(); } | ||||||
| })(document, window, "yandex_metrika_callbacks"); | ||||||
| <script type="text/javascript"> | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| (function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; | ||||||
| m[i].l=1*new Date(); | ||||||
| for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }} | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this is code from the Yandex documentation. Can you paste its source in the PR description, please? This loop may be written using forEach instead to avoid index errors. |
||||||
| k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)}) | ||||||
| (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym"); | ||||||
|
|
||||||
| ym(%(counter_id)s, "init", %(options)s); | ||||||
|
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This empty line is likely not needed. |
||||||
| </script> | ||||||
| <noscript><div><img src="https://mc.yandex.ru/watch/%(counter_id)s" style="position:absolute; left:-9999px;" alt="" /></div></noscript> | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is not part of your PR, but would be nice to be brought up-to-date with standards (HTML5).
Suggested change
|
||||||
| """ # noqa | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another user reported in #244 that the counter id can now be longer that 8 characters. Can you also adjust this regular expression accordingly?