Anchor links in posts
Adds the functional for creating anchors links (links to a specific fragment of the current post) to the reply form.
http://sf.uploads.ru/4jyOc.png

Authors: Fover & Deff
Platform: MyBB

Explanations:

Aim: to move the scrolling to a certain place of the page by clicking the link.
Useful when there are long explanations for something.
Example: in the descriptions of games, link lists, ingredients and the way to cook them.
HTML analogue: https://html.com/anchors-links/

anchor (red anchor) - the place where the scrolling will be moved - write the anchor name using latin lower case
anchor link (blue anchor) - paste to the anchor link the same word you used for the anchor name, and the word you need to the description

There is a feature of opening a spoiler when the anchor is in the spoiler or in its description

There is also a possibility to go to anchors from any page. The link in message should look like this:
[url=http://forum.mybb.ru/viewtopic.php?pid=31044#Name]Description[/url]
green - forum web address
blue - the number after #p after clicking the post publication date
red - anchor name


Version with opened icons:
https://i.imgur.com/oaenzWX.png

Code:
    <script type="text/javascript">
    $('#post').find("#button-addition").after('<td id="button-aanchor"><img style="width: 20px!important; height: 20px!important; margin-left: 4px!important;" src="http://forumfiles.ru/files/0012/e8/7a/38504.png" title="Insert the anchor" id="button-aanchor" onclick=\"addanchor()\"></td><td id="button-anchor"><img style="width: 20px!important; height: 20px!important; margin-left: 4px!important;" src="http://forumfiles.ru/files/0012/e8/7a/97990.png" title="Insert the anchor link" id="button-anchor" onclick=\"anchoru()\"></td>');
    function addanchor(){
     var adnchor = '';
     adnchor = prompt("Enter the anchor name", "#");
     insert("[url&" + adnchor + "]" + adnchor + "[/url]\n");
    }
    function anchoru(){
     var anchorp = '';
     anchorp = prompt("Enter the anchor name", "#");
     var anchorc = '';
     anchorc= prompt("Enter the anchor description", "Description");
     insert("[url=http://anchor" + anchorp + "]" + anchorc + "[/url]\n");
    }
    $('.post-content').each(function(){
     $(this).find('p:contains("[url&#"),div[onclick]:contains("[url&#")').each(function(){
       var str=$(this).html();
       var val = str.replace(/\[url&amp;#[^\[\]]+\]#([^\[\]]+)\[\/url\]/img,'<a name="$1"></a>');
       if(val!=str)$(this).html(val);   
     });
     $(this).find('a[href*="//anchor"]').each(function(){
       var href=$(this).attr('href');
         href = href.split('#')[1];
         if(!!href){$(this).removeAttr('target');$(this)[0].href = '#'+href;
           var str = $(this).text();
           if(str.indexOf('http://')==0)$(this).text(href);
         }
     });
    });
    $('.post-content').find('a[href^="#"]').live('click', function(){
        var lnk = $(this).attr('href');
        var a=$('.post-content').find('a[name="'+lnk.substr(1)+'"]');
        b = a.parents('.spoiler-box').find('div[onclick]:first').not('.visible');
        if(b.length)b.click();
        setTimeout(function(){location.replace(document.URL.split('#')[0]+lnk)},10)
        return false;
    });
    </script>

Version with icons hidden under the "Extra" button
https://i.imgur.com/14tUH33.png

Code:
    <script type="text/javascript">
    var img1 = "http://forumfiles.ru/files/0012/e8/7a/38504.png";
    var img2 = "http://forumfiles.ru/files/0012/e8/7a/97990.png";
     
    $('#post').find("#addition-area").prepend('<div onclick="addanchor()"><img style="width: 20px!important; height: 20px!important; margin:5px -3px -5px -14px!important;" src="'+img1+'"/> <span>Insert the anchor</span></div><div onclick="anchoru()" style="padding-bottom:4px"><img style="width: 20px!important; height: 20px!important; margin:5px 0 -5px -14px!important;" src="'+img2+'"/><span>Insert the anchor link</span></div>');
    function addanchor(){
     var adnchor = '';
     adnchor = prompt("Enter the anchor name", "#");
     insert("[url&" + adnchor + "]" + adnchor + "[/url]\n");
    }
    function anchoru(){
     var anchorp = '';
     anchorp = prompt("Enter the anchor name", "#");
     var anchorc = '';
     anchorc= prompt("Enter the anchor description", "Description");
     insert("[url=http://anchor" + anchorp + "]" + anchorc + "[/url]\n");
    }
    $('.post-content').each(function(){
     $(this).find('p:contains("[url&#"),div[onclick]:contains("[url&#")').each(function(){
       var str=$(this).html();
       var val = str.replace(/\[url&amp;#[^\[\]]+\]#([^\[\]]+)\[\/url\]/img,'<a name="$1"></a>');
       if(val!=str)$(this).html(val);   
     });
     $(this).find('a[href*="//anchor"]').each(function(){
       var href=$(this).attr('href');
         href = href.split('#')[1];
         if(!!href){$(this).removeAttr('target');$(this)[0].href = '#'+href;
           var str = $(this).text();
           if(str.indexOf('http://')==0)$(this).text(href);
         }
     });
    });
    $('.post-content').find('a[href^="#"]').live('click', function(){
        var lnk = $(this).attr('href');
        var a=$('.post-content').find('a[name="'+lnk.substr(1)+'"]');
        b = a.parents('.spoiler-box').find('div[onclick]:first').not('.visible');
        if(b.length)b.click();
        setTimeout(function(){location.replace(document.URL.split('#')[0]+lnk)},10)
        return false;
    });
    </script>