Igor150195

share

Dec 8th, 2025 (edited)
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1.  
  2. <script>
  3. $(function(){
  4. initShare();
  5.  
  6. function initShare() {
  7. $('.article-wrapper').each(function(){
  8. let slug = $(this).find('.dynamic-lazy-url span').text();
  9. let url = location.origin + slug;
  10. let $shareBtns = $(this).find('.article-share-btn');
  11.  
  12. $shareBtns.each(function(){
  13. let dataLink = $(this).data('link');
  14. let currentUrl = dataLink + url;
  15.  
  16. $(this).attr('href', currentUrl);
  17. });
  18. })
  19.  
  20. $('.article-copy-btn').on('click', function(e) {
  21. e.preventDefault();
  22.  
  23. if (navigator.clipboard) {
  24. navigator.clipboard.writeText(window.location.href).catch(function(){});
  25. }
  26. });
  27. };
  28.  
  29. const originalFetch = window.fetch;
  30.  
  31. window.fetch = function(...args) {
  32. return originalFetch.apply(this, args).then(response => {
  33. // Здесь выполняем свою функцию после fetch
  34. myAfterFetchFunction();
  35.  
  36. return response; // обязательно возвращаем ответ
  37. });
  38. };
  39.  
  40. function myAfterFetchFunction() {
  41. initShare();
  42. }
  43.  
  44. });
  45. </script>
Advertisement
Add Comment
Please, Sign In to add comment