Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type='text/javascript'>
- // Update {<opt first year SEP>this year} in the document, e.g. for copyright
- // First year and separator are skipped in the first year
- // Examples: {this year}, {2025 - this year} (equivalent in 2025)
- // Placed in the public domain by author Brian Katzung <[email protected]>
- // Based on an earlier version that had a jQuery dependency
- // **In a Kartra membership**, remove the // on the next line to hide the code block in preview and live
- // if (document.querySelector('head meta[name="description"]')) document.currentScript.parentElement.parentElement.style.display = 'none';
- ((fillYear) => {
- if (document.readyState === 'loading') {
- document.addEventListener('DOMContentLoaded', fillYear);
- } else {
- fillYear();
- }
- })(() => {
- // Example queries:
- // p (just within <p> paragraph tags)
- // p,div:not(:has(div)) (paragraphs and inner-most <div> tags)
- const query = 'p';
- const thisYear = new Date().getFullYear();
- document.querySelectorAll(query).forEach((node) => {
- if (node.innerHTML.match(/{[^}]*this year}/i)) {
- node.innerHTML = node.innerHTML.replace(/{[^}]*this year}/ig, (outer) => {
- const match = outer.match(/{(\d*)(.*)this year}/i);
- if (match[1] && parseInt(match[1]) !== thisYear) {
- return '' + match[1] + match[2] + thisYear;
- }
- return thisYear;
- });
- }
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment