MCPcopy
hub / github.com/Alanrk/LazyCat-Bookmark-Cleaner / initShareFeature

Function initShareFeature

bookmarkProfile.js:1892–1999  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1890}
1891// 在文件末尾添加分享相关函数
1892async function initShareFeature() {
1893 console.log('Initializing share feature...');
1894
1895 const shareButton = document.querySelector('.share-button');
1896 if (!shareButton) return;
1897
1898 console.log('Share button found:', shareButton);
1899
1900 // 移除所有现有的点击事件监听器
1901 shareButton.replaceWith(shareButton.cloneNode(true));
1902
1903 // 重新获取新的按钮元素
1904 const newShareButton = document.querySelector('.share-button');
1905
1906 // 添加单个事件监听器
1907 newShareButton?.addEventListener('click', async () => {
1908 console.log('Share button clicked');
1909 try {
1910 // 禁用按钮防止重复点击
1911 newShareButton.disabled = true;
1912
1913 const nickname = await getNickname();
1914 if (!nickname) {
1915 alert(getMessage('nicknameNotFound'));
1916 newShareButton.disabled = false;
1917 return;
1918 }
1919
1920 // 保存并修改分享按钮
1921 const originalShareButtonHtml = newShareButton.innerHTML;
1922 const originalShareButtonStyle = newShareButton.getAttribute('style');
1923
1924 // 将分享按钮改为品牌样式
1925 newShareButton.innerHTML = `
1926 <div class="brand" style="
1927 display: flex;
1928 align-items: center;
1929 gap: 8px;
1930 padding: 6px 12px;
1931 background: white;
1932 border-radius: 20px;
1933 border: 1px solid rgba(0, 0, 0, 0.05);
1934 ">
1935 <img src="images/logo.jpg" alt="懒猫书签清理" style="
1936 width: 20px;
1937 height: 20px;
1938 border-radius: 4px;
1939 ">
1940 <span style="
1941 color: #10b981;
1942 font-size: 14px;
1943 font-weight: 500;
1944 ">懒猫书签清理</span>
1945 </div>
1946 `;
1947 newShareButton.style.background = 'none';
1948 newShareButton.style.border = 'none';
1949 newShareButton.style.padding = '0';

Callers 1

bookmarkProfile.jsFile · 0.85

Calls 2

getNicknameFunction · 0.85
getMessageFunction · 0.70

Tested by

no test coverage detected