Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- $(function(){
- initShare();
- function initShare() {
- $('.article-wrapper').each(function(){
- let slug = $(this).find('.dynamic-lazy-url span').text();
- let url = location.origin + slug;
- let $shareBtns = $(this).find('.article-share-btn');
- $shareBtns.each(function(){
- let dataLink = $(this).data('link');
- let currentUrl = dataLink + url;
- $(this).attr('href', currentUrl);
- });
- })
- $('.article-copy-btn').on('click', function(e) {
- e.preventDefault();
- if (navigator.clipboard) {
- navigator.clipboard.writeText(window.location.href).catch(function(){});
- }
- });
- };
- const originalFetch = window.fetch;
- window.fetch = function(...args) {
- return originalFetch.apply(this, args).then(response => {
- // Здесь выполняем свою функцию после fetch
- myAfterFetchFunction();
- return response; // обязательно возвращаем ответ
- });
- };
- function myAfterFetchFunction() {
- initShare();
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment