המלצה | סקריפט לטמפרמונקי לסינון הנושאים לפי סוג! (מדריך, בעיה וכו')
-
תודה לperplexity

// ==UserScript== // @name מתמחים טופ - סינון נושאים לפי תגיות (ריבוי תגיות + טעינה דינמית) // @namespace http://tampermonkey.net/ // @version 3.0 // @description סינון <li class="category-item"> בדף user/*/topics לפי תגיות span (המלצה, בקשה וכו'), כולל נושאים שנוספים בגלילה/דפדוף. // @match https://mitmachim.top/user/*/topics // @match https://www.mitmachim.top/user/*/topics // @grant none // ==/UserScript== (function () { 'use strict'; // --- עזר בסיסי --- function getTagFromRow(row) { const link = row.querySelector('h3[component="topic/header"] a.text-reset'); if (!link) return ''; const span = link.querySelector('span'); if (!span) return ''; const clone = span.cloneNode(true); clone.querySelectorAll('i, svg').forEach(el => el.remove()); return clone.textContent.replace(/\s+/g, ' ').trim(); } function slugifyTag(tag) { return tag .replace(/\s+/g, '-') // רווחים -> מקף .replace(/[^\w\u0590-\u05FF-]/g, ''); // מסיר תווים בעייתיים (משאיר אותיות/ספרות/עברית/מקף) } // --- מצב גלובלי --- let currentRows = []; let currentTagInfos = []; let filterPanel = null; function getSelectedSlugs() { if (!filterPanel) return []; return Array.from(filterPanel.querySelectorAll('input[type="checkbox"]:checked')) .map(chk => chk.value); } // --- תיוג שורות לפי תגיות --- function addTagClasses(rows) { const tagSet = new Set(); rows.forEach(row => { const tag = getTagFromRow(row); if (!tag) return; const slug = slugifyTag(tag); row.classList.add('topic-tag-' + slug); tagSet.add(JSON.stringify({ tag, slug })); }); return Array.from(tagSet).map(str => JSON.parse(str)); } // --- יצירת / עדכון פאנל סינון --- function ensureGlobalCSS() { if (document.getElementById('topics-tag-filter-css')) return; const css = ` li.category-item[component="category/topic"] { display: flex; } body.has-topic-filter li.category-item[component="category/topic"] { display: none !important; } body.has-topic-filter li.category-item[component="category/topic"].topic-tag-selected { display: flex !important; } `; const style = document.createElement('style'); style.id = 'topics-tag-filter-css'; style.textContent = css; document.documentElement.appendChild(style); } function createOrUpdateFilterPanel(list, tagInfos) { ensureGlobalCSS(); if (!filterPanel) { // יצירה ראשונית const panel = document.createElement('div'); panel.style.margin = '10px 0'; panel.style.padding = '10px'; panel.style.border = '1px solid #ccc'; panel.style.background = '#f9f9f9'; panel.style.display = 'flex'; panel.style.flexWrap = 'wrap'; panel.style.alignItems = 'center'; panel.style.gap = '8px'; panel.style.direction = 'rtl'; const title = document.createElement('span'); title.textContent = 'סינון לפי תגיות נושא:'; title.style.fontWeight = 'bold'; panel.appendChild(title); const clearBtn = document.createElement('button'); clearBtn.type = 'button'; clearBtn.textContent = 'הכול'; clearBtn.style.marginInlineStart = '8px'; clearBtn.style.padding = '2px 6px'; clearBtn.style.fontSize = '12px'; clearBtn.addEventListener('click', () => { panel.querySelectorAll('input[type="checkbox"]').forEach(chk => chk.checked = false); applyFilter([]); // אין תגיות מסומנות }); panel.appendChild(clearBtn); const tagsContainer = document.createElement('div'); tagsContainer.className = 'tags-container'; tagsContainer.style.display = 'flex'; tagsContainer.style.flexWrap = 'wrap'; tagsContainer.style.gap = '6px'; tagsContainer.style.alignItems = 'center'; panel.appendChild(tagsContainer); const note = document.createElement('span'); note.textContent = ' (אפשר לבחור כמה תגיות; מוצגים נושאים שיש להם לפחות אחת מהן)'; note.style.fontSize = '11px'; note.style.color = '#666'; note.style.width = '100%'; panel.appendChild(note); list.parentElement.insertBefore(panel, list); panel.addEventListener('change', () => { const selected = getSelectedSlugs(); applyFilter(selected); }); filterPanel = panel; } // עדכון רשימת הצ'קבוקסים (איחוד תגיות מכל העמוד/גלילות) const tagsContainer = filterPanel.querySelector('.tags-container'); const existingSlugs = new Set(Array.from(tagsContainer.querySelectorAll('input[type="checkbox"]')).map(chk => chk.value)); const selectedBefore = new Set(getSelectedSlugs()); tagInfos.forEach(info => { if (existingSlugs.has(info.slug)) return; const wrapper = document.createElement('label'); wrapper.style.display = 'flex'; wrapper.style.alignItems = 'center'; wrapper.style.gap = '4px'; wrapper.style.fontSize = '12px'; const chk = document.createElement('input'); chk.type = 'checkbox'; chk.value = info.slug; if (selectedBefore.has(info.slug)) chk.checked = true; const span = document.createElement('span'); span.textContent = info.tag; wrapper.appendChild(chk); wrapper.appendChild(span); tagsContainer.appendChild(wrapper); }); } // --- סינון בפועל --- function applyFilter(selectedSlugs) { const rows = currentRows; if (!rows.length) return; if (!selectedSlugs || !selectedSlugs.length) { document.body.classList.remove('has-topic-filter'); rows.forEach(row => { row.classList.remove('topic-tag-selected'); row.style.display = 'flex'; }); return; } document.body.classList.add('has-topic-filter'); rows.forEach(row => { const hasAny = selectedSlugs.some(slug => row.classList.contains('topic-tag-' + slug)); if (hasAny) { row.classList.add('topic-tag-selected'); } else { row.classList.remove('topic-tag-selected'); } }); } // --- סריקה מחדש של הדף (לדף חדש / גלילה חדשה) --- function rescan() { const root = document.querySelector('#ajaxify') || document.querySelector('#content') || document.body; if (!root) return; const rows = Array.from(root.querySelectorAll('li.category-item[component="category/topic"]')); if (!rows.length) return; currentRows = rows; const tagInfos = addTagClasses(rows); currentTagInfos = mergeTagInfos(currentTagInfos, tagInfos); const list = rows[0].parentElement; createOrUpdateFilterPanel(list, currentTagInfos); // להחיל מחדש את הסינון לפי מה שכבר מסומן const selected = getSelectedSlugs(); if (selected.length) { applyFilter(selected); } } function mergeTagInfos(oldInfos, newInfos) { const map = new Map(); [...oldInfos, ...newInfos].forEach(info => { map.set(info.slug, info); }); return Array.from(map.values()); } // --- התחלה + MutationObserver לטעינה דינמית --- function start() { rescan(); const ajaxify = document.querySelector('#ajaxify') || document.querySelector('#content') || document.body; if (!ajaxify) return; const observer = new MutationObserver((mutations) => { // כל שינוי משמעותי ב־childList גורר rescan if (mutations.some(m => m.type === 'childList' && m.addedNodes.length)) { rescan(); } }); observer.observe(ajaxify, { childList: true, subtree: true }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', start); } else { start(); } })(); -
תודה לperplexity

// ==UserScript== // @name מתמחים טופ - סינון נושאים לפי תגיות (ריבוי תגיות + טעינה דינמית) // @namespace http://tampermonkey.net/ // @version 3.0 // @description סינון <li class="category-item"> בדף user/*/topics לפי תגיות span (המלצה, בקשה וכו'), כולל נושאים שנוספים בגלילה/דפדוף. // @match https://mitmachim.top/user/*/topics // @match https://www.mitmachim.top/user/*/topics // @grant none // ==/UserScript== (function () { 'use strict'; // --- עזר בסיסי --- function getTagFromRow(row) { const link = row.querySelector('h3[component="topic/header"] a.text-reset'); if (!link) return ''; const span = link.querySelector('span'); if (!span) return ''; const clone = span.cloneNode(true); clone.querySelectorAll('i, svg').forEach(el => el.remove()); return clone.textContent.replace(/\s+/g, ' ').trim(); } function slugifyTag(tag) { return tag .replace(/\s+/g, '-') // רווחים -> מקף .replace(/[^\w\u0590-\u05FF-]/g, ''); // מסיר תווים בעייתיים (משאיר אותיות/ספרות/עברית/מקף) } // --- מצב גלובלי --- let currentRows = []; let currentTagInfos = []; let filterPanel = null; function getSelectedSlugs() { if (!filterPanel) return []; return Array.from(filterPanel.querySelectorAll('input[type="checkbox"]:checked')) .map(chk => chk.value); } // --- תיוג שורות לפי תגיות --- function addTagClasses(rows) { const tagSet = new Set(); rows.forEach(row => { const tag = getTagFromRow(row); if (!tag) return; const slug = slugifyTag(tag); row.classList.add('topic-tag-' + slug); tagSet.add(JSON.stringify({ tag, slug })); }); return Array.from(tagSet).map(str => JSON.parse(str)); } // --- יצירת / עדכון פאנל סינון --- function ensureGlobalCSS() { if (document.getElementById('topics-tag-filter-css')) return; const css = ` li.category-item[component="category/topic"] { display: flex; } body.has-topic-filter li.category-item[component="category/topic"] { display: none !important; } body.has-topic-filter li.category-item[component="category/topic"].topic-tag-selected { display: flex !important; } `; const style = document.createElement('style'); style.id = 'topics-tag-filter-css'; style.textContent = css; document.documentElement.appendChild(style); } function createOrUpdateFilterPanel(list, tagInfos) { ensureGlobalCSS(); if (!filterPanel) { // יצירה ראשונית const panel = document.createElement('div'); panel.style.margin = '10px 0'; panel.style.padding = '10px'; panel.style.border = '1px solid #ccc'; panel.style.background = '#f9f9f9'; panel.style.display = 'flex'; panel.style.flexWrap = 'wrap'; panel.style.alignItems = 'center'; panel.style.gap = '8px'; panel.style.direction = 'rtl'; const title = document.createElement('span'); title.textContent = 'סינון לפי תגיות נושא:'; title.style.fontWeight = 'bold'; panel.appendChild(title); const clearBtn = document.createElement('button'); clearBtn.type = 'button'; clearBtn.textContent = 'הכול'; clearBtn.style.marginInlineStart = '8px'; clearBtn.style.padding = '2px 6px'; clearBtn.style.fontSize = '12px'; clearBtn.addEventListener('click', () => { panel.querySelectorAll('input[type="checkbox"]').forEach(chk => chk.checked = false); applyFilter([]); // אין תגיות מסומנות }); panel.appendChild(clearBtn); const tagsContainer = document.createElement('div'); tagsContainer.className = 'tags-container'; tagsContainer.style.display = 'flex'; tagsContainer.style.flexWrap = 'wrap'; tagsContainer.style.gap = '6px'; tagsContainer.style.alignItems = 'center'; panel.appendChild(tagsContainer); const note = document.createElement('span'); note.textContent = ' (אפשר לבחור כמה תגיות; מוצגים נושאים שיש להם לפחות אחת מהן)'; note.style.fontSize = '11px'; note.style.color = '#666'; note.style.width = '100%'; panel.appendChild(note); list.parentElement.insertBefore(panel, list); panel.addEventListener('change', () => { const selected = getSelectedSlugs(); applyFilter(selected); }); filterPanel = panel; } // עדכון רשימת הצ'קבוקסים (איחוד תגיות מכל העמוד/גלילות) const tagsContainer = filterPanel.querySelector('.tags-container'); const existingSlugs = new Set(Array.from(tagsContainer.querySelectorAll('input[type="checkbox"]')).map(chk => chk.value)); const selectedBefore = new Set(getSelectedSlugs()); tagInfos.forEach(info => { if (existingSlugs.has(info.slug)) return; const wrapper = document.createElement('label'); wrapper.style.display = 'flex'; wrapper.style.alignItems = 'center'; wrapper.style.gap = '4px'; wrapper.style.fontSize = '12px'; const chk = document.createElement('input'); chk.type = 'checkbox'; chk.value = info.slug; if (selectedBefore.has(info.slug)) chk.checked = true; const span = document.createElement('span'); span.textContent = info.tag; wrapper.appendChild(chk); wrapper.appendChild(span); tagsContainer.appendChild(wrapper); }); } // --- סינון בפועל --- function applyFilter(selectedSlugs) { const rows = currentRows; if (!rows.length) return; if (!selectedSlugs || !selectedSlugs.length) { document.body.classList.remove('has-topic-filter'); rows.forEach(row => { row.classList.remove('topic-tag-selected'); row.style.display = 'flex'; }); return; } document.body.classList.add('has-topic-filter'); rows.forEach(row => { const hasAny = selectedSlugs.some(slug => row.classList.contains('topic-tag-' + slug)); if (hasAny) { row.classList.add('topic-tag-selected'); } else { row.classList.remove('topic-tag-selected'); } }); } // --- סריקה מחדש של הדף (לדף חדש / גלילה חדשה) --- function rescan() { const root = document.querySelector('#ajaxify') || document.querySelector('#content') || document.body; if (!root) return; const rows = Array.from(root.querySelectorAll('li.category-item[component="category/topic"]')); if (!rows.length) return; currentRows = rows; const tagInfos = addTagClasses(rows); currentTagInfos = mergeTagInfos(currentTagInfos, tagInfos); const list = rows[0].parentElement; createOrUpdateFilterPanel(list, currentTagInfos); // להחיל מחדש את הסינון לפי מה שכבר מסומן const selected = getSelectedSlugs(); if (selected.length) { applyFilter(selected); } } function mergeTagInfos(oldInfos, newInfos) { const map = new Map(); [...oldInfos, ...newInfos].forEach(info => { map.set(info.slug, info); }); return Array.from(map.values()); } // --- התחלה + MutationObserver לטעינה דינמית --- function start() { rescan(); const ajaxify = document.querySelector('#ajaxify') || document.querySelector('#content') || document.body; if (!ajaxify) return; const observer = new MutationObserver((mutations) => { // כל שינוי משמעותי ב־childList גורר rescan if (mutations.some(m => m.type === 'childList' && m.addedNodes.length)) { rescan(); } }); observer.observe(ajaxify, { childList: true, subtree: true }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', start); } else { start(); } })();@מחנה-ידידים אפשר טיפה יותר פירוט מה הסקריפט הזה עושה?
-
@מחנה-ידידים אפשר טיפה יותר פירוט מה הסקריפט הזה עושה?
מוסיף תיבת סינון

-
מוסיף תיבת סינון

@מחנה-ידידים יפה!
האמת שחשבתי על זה למה אין את זה...
בכ"א אין שם להורדה... למה? -
@מחנה-ידידים יפה!
האמת שחשבתי על זה למה אין את זה...
בכ"א אין שם להורדה... למה?@חייא-שיאומי זה מציג לפי הנושאים שלך... אין לי נושא עם תג "להורדה"
-
תודה לperplexity

// ==UserScript== // @name מתמחים טופ - סינון נושאים לפי תגיות (ריבוי תגיות + טעינה דינמית) // @namespace http://tampermonkey.net/ // @version 3.0 // @description סינון <li class="category-item"> בדף user/*/topics לפי תגיות span (המלצה, בקשה וכו'), כולל נושאים שנוספים בגלילה/דפדוף. // @match https://mitmachim.top/user/*/topics // @match https://www.mitmachim.top/user/*/topics // @grant none // ==/UserScript== (function () { 'use strict'; // --- עזר בסיסי --- function getTagFromRow(row) { const link = row.querySelector('h3[component="topic/header"] a.text-reset'); if (!link) return ''; const span = link.querySelector('span'); if (!span) return ''; const clone = span.cloneNode(true); clone.querySelectorAll('i, svg').forEach(el => el.remove()); return clone.textContent.replace(/\s+/g, ' ').trim(); } function slugifyTag(tag) { return tag .replace(/\s+/g, '-') // רווחים -> מקף .replace(/[^\w\u0590-\u05FF-]/g, ''); // מסיר תווים בעייתיים (משאיר אותיות/ספרות/עברית/מקף) } // --- מצב גלובלי --- let currentRows = []; let currentTagInfos = []; let filterPanel = null; function getSelectedSlugs() { if (!filterPanel) return []; return Array.from(filterPanel.querySelectorAll('input[type="checkbox"]:checked')) .map(chk => chk.value); } // --- תיוג שורות לפי תגיות --- function addTagClasses(rows) { const tagSet = new Set(); rows.forEach(row => { const tag = getTagFromRow(row); if (!tag) return; const slug = slugifyTag(tag); row.classList.add('topic-tag-' + slug); tagSet.add(JSON.stringify({ tag, slug })); }); return Array.from(tagSet).map(str => JSON.parse(str)); } // --- יצירת / עדכון פאנל סינון --- function ensureGlobalCSS() { if (document.getElementById('topics-tag-filter-css')) return; const css = ` li.category-item[component="category/topic"] { display: flex; } body.has-topic-filter li.category-item[component="category/topic"] { display: none !important; } body.has-topic-filter li.category-item[component="category/topic"].topic-tag-selected { display: flex !important; } `; const style = document.createElement('style'); style.id = 'topics-tag-filter-css'; style.textContent = css; document.documentElement.appendChild(style); } function createOrUpdateFilterPanel(list, tagInfos) { ensureGlobalCSS(); if (!filterPanel) { // יצירה ראשונית const panel = document.createElement('div'); panel.style.margin = '10px 0'; panel.style.padding = '10px'; panel.style.border = '1px solid #ccc'; panel.style.background = '#f9f9f9'; panel.style.display = 'flex'; panel.style.flexWrap = 'wrap'; panel.style.alignItems = 'center'; panel.style.gap = '8px'; panel.style.direction = 'rtl'; const title = document.createElement('span'); title.textContent = 'סינון לפי תגיות נושא:'; title.style.fontWeight = 'bold'; panel.appendChild(title); const clearBtn = document.createElement('button'); clearBtn.type = 'button'; clearBtn.textContent = 'הכול'; clearBtn.style.marginInlineStart = '8px'; clearBtn.style.padding = '2px 6px'; clearBtn.style.fontSize = '12px'; clearBtn.addEventListener('click', () => { panel.querySelectorAll('input[type="checkbox"]').forEach(chk => chk.checked = false); applyFilter([]); // אין תגיות מסומנות }); panel.appendChild(clearBtn); const tagsContainer = document.createElement('div'); tagsContainer.className = 'tags-container'; tagsContainer.style.display = 'flex'; tagsContainer.style.flexWrap = 'wrap'; tagsContainer.style.gap = '6px'; tagsContainer.style.alignItems = 'center'; panel.appendChild(tagsContainer); const note = document.createElement('span'); note.textContent = ' (אפשר לבחור כמה תגיות; מוצגים נושאים שיש להם לפחות אחת מהן)'; note.style.fontSize = '11px'; note.style.color = '#666'; note.style.width = '100%'; panel.appendChild(note); list.parentElement.insertBefore(panel, list); panel.addEventListener('change', () => { const selected = getSelectedSlugs(); applyFilter(selected); }); filterPanel = panel; } // עדכון רשימת הצ'קבוקסים (איחוד תגיות מכל העמוד/גלילות) const tagsContainer = filterPanel.querySelector('.tags-container'); const existingSlugs = new Set(Array.from(tagsContainer.querySelectorAll('input[type="checkbox"]')).map(chk => chk.value)); const selectedBefore = new Set(getSelectedSlugs()); tagInfos.forEach(info => { if (existingSlugs.has(info.slug)) return; const wrapper = document.createElement('label'); wrapper.style.display = 'flex'; wrapper.style.alignItems = 'center'; wrapper.style.gap = '4px'; wrapper.style.fontSize = '12px'; const chk = document.createElement('input'); chk.type = 'checkbox'; chk.value = info.slug; if (selectedBefore.has(info.slug)) chk.checked = true; const span = document.createElement('span'); span.textContent = info.tag; wrapper.appendChild(chk); wrapper.appendChild(span); tagsContainer.appendChild(wrapper); }); } // --- סינון בפועל --- function applyFilter(selectedSlugs) { const rows = currentRows; if (!rows.length) return; if (!selectedSlugs || !selectedSlugs.length) { document.body.classList.remove('has-topic-filter'); rows.forEach(row => { row.classList.remove('topic-tag-selected'); row.style.display = 'flex'; }); return; } document.body.classList.add('has-topic-filter'); rows.forEach(row => { const hasAny = selectedSlugs.some(slug => row.classList.contains('topic-tag-' + slug)); if (hasAny) { row.classList.add('topic-tag-selected'); } else { row.classList.remove('topic-tag-selected'); } }); } // --- סריקה מחדש של הדף (לדף חדש / גלילה חדשה) --- function rescan() { const root = document.querySelector('#ajaxify') || document.querySelector('#content') || document.body; if (!root) return; const rows = Array.from(root.querySelectorAll('li.category-item[component="category/topic"]')); if (!rows.length) return; currentRows = rows; const tagInfos = addTagClasses(rows); currentTagInfos = mergeTagInfos(currentTagInfos, tagInfos); const list = rows[0].parentElement; createOrUpdateFilterPanel(list, currentTagInfos); // להחיל מחדש את הסינון לפי מה שכבר מסומן const selected = getSelectedSlugs(); if (selected.length) { applyFilter(selected); } } function mergeTagInfos(oldInfos, newInfos) { const map = new Map(); [...oldInfos, ...newInfos].forEach(info => { map.set(info.slug, info); }); return Array.from(map.values()); } // --- התחלה + MutationObserver לטעינה דינמית --- function start() { rescan(); const ajaxify = document.querySelector('#ajaxify') || document.querySelector('#content') || document.body; if (!ajaxify) return; const observer = new MutationObserver((mutations) => { // כל שינוי משמעותי ב־childList גורר rescan if (mutations.some(m => m.type === 'childList' && m.addedNodes.length)) { rescan(); } }); observer.observe(ajaxify, { childList: true, subtree: true }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', start); } else { start(); } })(); -
@מוצ תרענן את https://mitmachim.top/me/topics
-
@מוצ תרענן את https://mitmachim.top/me/topics
@מחנה-ידידים יפה תודה!
שלום! נראה שהשיחה הזו מעניינת אותך, אבל עדיין אין לך חשבון.
נמאס לכם לגלול בין אותם הפוסטים בכל ביקור? כשנרשמים לחשבון, תמיד תחזרו בדיוק למקום שבו הייתם קודם, ותוכלו לבחור לקבל התראות על תגובות חדשות (בין אם במייל, ובין אם בהתראת פוש). תוכלו גם לשמור סימניות ולפרגן ב-upvote לפוסטים כדי להביע הערכה לחברי קהילה אחרים.
בעזרת התרומה שלך, הפוסט הזה יכול להיות אפילו טוב יותר 💗
הרשמה התחברות