תפריט פרומפטים ל-chatGPT
כתבתי תוסף לכרום שמוסיף את התפריט באופן אוטומטי (עם אפשרות למזעור או סגירה)
(() => {
const style = document.createElement('style');
style.textContent = `
#floatingMenu {
position: fixed;
top: 100px;
right: 10px;
width: 270px;
max-height: 400px;
background: rgba(0,0,0,0.6);
color: white;
font-family: Arial, sans-serif;
font-size: 14px;
border-radius: 6px;
box-shadow: 0 0 10px black;
display: flex;
flex-direction: column;
user-select: none;
z-index: 999999;
overflow: hidden;
transition: max-height 0.4s ease;
}
#floatingMenu.collapsed {
max-height: 40px;
}
#floatingMenuHeader {
padding: 8px 10px;
background: rgba(0,0,0,0.8);
cursor: move;
display: flex;
justify-content: space-between;
align-items: center;
font-weight: bold;
}
#floatingMenuTitle {
flex-grow: 1;
text-align: center;
}
#floatingMenuControls {
display: flex;
align-items: center;
}
#floatingMenuControls > button {
cursor: pointer;
margin-left: 10px;
font-weight: bold;
background: none;
border: none;
color: white;
font-size: 16px;
line-height: 1;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
}
#floatingMenuControls > button:focus {
outline: 2px solid #fff;
outline-offset: 2px;
}
#searchInput {
margin: 0 10px;
padding: 5px 8px;
border-radius: 4px;
border: none;
font-size: 14px;
width: calc(100% - 20px);
box-sizing: border-box;
max-height: 0;
opacity: 0;
pointer-events: none;
transition: max-height 0.4s ease, opacity 0.4s ease, margin 0.4s ease;
direction: rtl;
}
#searchInput.visible {
max-height: 40px;
opacity: 1;
pointer-events: auto;
margin: 5px 10px;
}
#floatingMenuList {
padding: 5px 10px;
transition: opacity 0.3s ease;
flex-grow: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
#floatingMenuList.scrollable {
overflow-y: auto;
max-height: 340px;
}
#floatingMenuList div {
padding: 5px 8px;
border-radius: 4px;
margin-bottom: 4px;
background: rgba(255,255,255,0.1);
cursor: pointer;
white-space: nowrap;
text-overflow: ellipsis;
}
#floatingMenuList div:hover,
#floatingMenuList div:focus {
background: rgba(255,255,255,0.25);
outline: none;
}
#floatingMenu.collapsed #searchInput,
#floatingMenu.collapsed #floatingMenuList {
opacity: 0;
pointer-events: none;
height: 0;
padding: 0 10px;
overflow: hidden !important;
transition: opacity 0.4s ease, height 0.4s ease, padding 0.4s ease, margin 0.4s ease;
}
`;
document.head.appendChild(style);
const menu = document.createElement('div');
menu.id = 'floatingMenu';
menu.setAttribute('role', 'region');
menu.setAttribute('aria-label', 'תפריט שאלות');
const header = document.createElement('div');
header.id = 'floatingMenuHeader';
header.setAttribute('role', 'banner');
const title = document.createElement('div');
title.id = 'floatingMenuTitle';
title.textContent = 'ריק'; // ברירת מחדל
const controls = document.createElement('div');
controls.id = 'floatingMenuControls';
const toggleSearchBtn = document.createElement('button');
toggleSearchBtn.id = 'toggleSearchBtn';
toggleSearchBtn.textContent = '?';
const collapseBtn = document.createElement('button');
collapseBtn.id = 'collapseBtn';
collapseBtn.textContent = '-';
const closeBtn = document.createElement('button');
closeBtn.id = 'closeBtn';
closeBtn.textContent = '×';
controls.appendChild(toggleSearchBtn);
controls.appendChild(collapseBtn);
controls.appendChild(closeBtn);
header.appendChild(title);
header.appendChild(controls);
const searchInput = document.createElement('input');
searchInput.id = 'searchInput';
searchInput.type = 'search';
searchInput.placeholder = 'חפש שאלות...';
const listContainer = document.createElement('div');
listContainer.id = 'floatingMenuList';
menu.appendChild(header);
menu.appendChild(searchInput);
menu.appendChild(listContainer);
document.body.appendChild(menu);
function isHebrewChar(char) {
return /[\u0590-\u05FF]/.test(char);
}
function hasClassOrParentHasClass(el, className) {
while (el) {
if (el.classList && el.classList.contains(className)) {
return true;
}
el = el.parentElement;
}
return false;
}
function getQuestions() {
const qs = document.querySelectorAll('.whitespace-pre-wrap');
const questions = [];
qs.forEach((q, i) => {
let len = 27;
if (hasClassOrParentHasClass(q, 'text-page-header')) return;
let text = q.textContent.trim().replace(/\s+/g, ' ');
if (text.length > len) text = text.slice(0, len) + '…';
questions.push({ el: q, text, index: i, fullText: q.textContent.trim() });
});
return questions;
}
let previousQuestionsJSON = null;
function updateList() {
const questions = getQuestions();
const currentQuestionsJSON = JSON.stringify(questions.map(q => q.fullText));
if (currentQuestionsJSON === previousQuestionsJSON) return;
previousQuestionsJSON = currentQuestionsJSON;
if (questions.length === 0) {
title.textContent = 'ריק';
} else {
title.textContent = document.title || 'צ׳אט';
}
// 👇 בדיקת כיוון הכותרת
const firstChar = title.textContent.trim().charAt(0);
if (isHebrewChar(firstChar)) {
title.style.direction = 'rtl';
} else {
title.style.direction = 'ltr';
}
const searchTerm = searchInput.value.trim().toLowerCase();
listContainer.innerHTML = '';
const filtered = questions.filter(q => q.fullText.toLowerCase().includes(searchTerm));
listContainer.classList.toggle('scrollable', filtered.length > 10);
if (filtered.length === 0) {
const noResultDiv = document.createElement('div');
noResultDiv.textContent = 'לא נמצאו שאלות';
noResultDiv.style.textAlign = 'center';
noResultDiv.style.opacity = '0.7';
listContainer.appendChild(noResultDiv);
return;
}
filtered.forEach(({ el, text, index, fullText }) => {
const item = document.createElement('div');
item.textContent = text || `שאלה ${index + 1}`;
item.title = fullText;
if (isHebrewChar(text[0])) {
item.style.direction = 'rtl';
item.style.textAlign = 'right';
} else {
item.style.direction = 'ltr';
item.style.textAlign = 'left';
}
item.addEventListener('click', e => {
e.preventDefault();
el.scrollIntoView({ behavior: 'smooth', block: 'center' });
el.style.transition = 'background-color 0.5s';
const origBG = el.style.backgroundColor;
el.style.backgroundColor = 'yellow';
setTimeout(() => {
el.style.backgroundColor = origBG || '';
}, 1000);
});
listContainer.appendChild(item);
});
}
closeBtn.addEventListener('click', () => {
menu.style.display = 'none';
});
collapseBtn.addEventListener('click', () => {
const isCollapsed = menu.classList.toggle('collapsed');
collapseBtn.textContent = isCollapsed ? '+' : '-';
});
toggleSearchBtn.addEventListener('click', () => {
const visible = searchInput.classList.toggle('visible');
if (visible) {
searchInput.focus();
} else {
searchInput.value = '';
updateList();
}
});
searchInput.addEventListener('input', () => {
updateList();
});
let isDragging = false, dragStartX, dragStartY, menuStartX, menuStartY;
header.addEventListener('mousedown', e => {
isDragging = true;
dragStartX = e.clientX;
dragStartY = e.clientY;
const rect = menu.getBoundingClientRect();
menuStartX = rect.left;
menuStartY = rect.top;
e.preventDefault();
});
window.addEventListener('mousemove', e => {
if (!isDragging) return;
let newX = menuStartX + (e.clientX - dragStartX);
let newY = menuStartY + (e.clientY - dragStartY);
const maxX = window.innerWidth - menu.offsetWidth - 10;
const maxY = window.innerHeight - menu.offsetHeight - 10;
newX = Math.max(0, Math.min(maxX, newX));
newY = Math.max(0, Math.min(maxY, newY));
menu.style.right = 'auto';
menu.style.left = `${newX}px`;
menu.style.top = `${newY}px`;
});
window.addEventListener('mouseup', () => {
isDragging = false;
});
const observer = new MutationObserver(() => {
updateList();
});
observer.observe(document.body, { childList: true, subtree: true, characterData: true });
updateList();
})();
אם לא ניתן להתקין תוספים אצלך בדפדן, אז אפשר להפעיל את זה בדרך הבאה:
- לחץ כאן כדי להעתיק את הקוד
- העתק מכאן את הקוד
- לחץ ctrl+d כדי ליצור סימניה
- שנה את שם הסימניה ל-תפריט, ובמקום כתובת, הדבק את הטקסט שהעתקת בסעיף 1
- בזמן שימוש באתר ChatGPT, לחץ על הסימניה ששמרת כדי להציג את התפריט
javascript:(()=>{const e=document.createElement("style");e.textContent="#floatingMenu{position:fixed;top:100px;right:10px;width:270px;max-height:400px;background:rgba(0,0,0,.6);color:#fff;font-family:Arial,sans-serif;font-size:14px;border-radius:6px;box-shadow:0 0 10px black;display:flex;flex-direction:column;user-select:none;z-index:999999;overflow:hidden;transition:max-height .4s ease}#floatingMenu.collapsed{max-height:40px}#floatingMenuHeader{padding:8px 10px;background:rgba(0,0,0,.8);cursor:move;display:flex;justify-content:space-between;align-items:center;font-weight:700}#floatingMenuTitle{flex-grow:1;text-align:center}#floatingMenuControls{display:flex;align-items:center}#floatingMenuControls>button{cursor:pointer;margin-left:10px;font-weight:700;background:none;border:none;color:#fff;font-size:16px;line-height:1;padding:0;display:flex;align-items:center;justify-content:center}#floatingMenuControls>button:focus{outline:2px solid #fff;outline-offset:2px}#searchInput{margin:0 10px;padding:5px 8px;border-radius:4px;border:none;font-size:14px;width:calc(100% - 20px);box-sizing:border-box;max-height:0;opacity:0;pointer-events:none;transition:max-height .4s ease,opacity .4s ease,margin .4s ease;direction:rtl}#searchInput.visible{max-height:40px;opacity:1;pointer-events:auto;margin:5px 10px}#floatingMenuList{padding:5px 10px;transition:opacity .3s ease;flex-grow:1;display:flex;flex-direction:column;overflow:hidden}#floatingMenuList.scrollable{overflow-y:auto;max-height:340px}#floatingMenuList div{padding:5px 8px;border-radius:4px;margin-bottom:4px;background:rgba(255,255,255,.1);cursor:pointer;white-space:nowrap;text-overflow:ellipsis}#floatingMenuList div:hover,#floatingMenuList div:focus{background:rgba(255,255,255,.25);outline:none}#floatingMenu.collapsed #searchInput,#floatingMenu.collapsed #floatingMenuList{opacity:0;pointer-events:none;height:0;padding:0 10px;overflow:hidden!important;transition:opacity .4s ease,height .4s ease,padding .4s ease,margin .4s ease}",document.head.appendChild(e);const t=document.createElement("div");t.id="floatingMenu",t.setAttribute("role","region"),t.setAttribute("aria-label","תפריט שאלות");const n=document.createElement("div");n.id="floatingMenuHeader",n.setAttribute("role","banner");const o=document.createElement("div");o.id="floatingMenuTitle",o.textContent="ריק";const i=document.createElement("div");i.id="floatingMenuControls";const l=document.createElement("button");l.id="toggleSearchBtn",l.textContent="?";const a=document.createElement("button");a.id="collapseBtn",a.textContent="-";const c=document.createElement("button");c.id="closeBtn",c.textContent="×",i.appendChild(l),i.appendChild(a),i.appendChild(c),n.appendChild(o),n.appendChild(i);const s=document.createElement("input");s.id="searchInput",s.type="search",s.placeholder="חפש שאלות...";const d=document.createElement("div");d.id="floatingMenuList",t.appendChild(n),t.appendChild(s),t.appendChild(d),document.body.appendChild(t);function p(e){return/[\u0590-\u05FF]/.test(e)}function u(e,t){for(;e;){if(e.classList&&e.classList.contains(t))return!0;e=e.parentElement}return!1}function f(){const e=document.querySelectorAll(".whitespace-pre-wrap"),t=[];return e.forEach(((e,n)=>{let o=27;if(u(e,"text-page-header"))return;let i=e.textContent.trim().replace(/\s+/g," ");i.length>o&&(i=i.slice(0,o)+"…"),t.push({el:e,text:i,index:n,fullText:e.textContent.trim()})})),t}let r=null;function m(){const e=f(),n=JSON.stringify(e.map((e=>e.fullText)));if(n===r)return;r=n,0===e.length?o.textContent="ריק":o.textContent=document.title||"צ׳אט";const i=o.textContent.trim().charAt(0);p(i)?o.style.direction="rtl":o.style.direction="ltr";const l=s.value.trim().toLowerCase();d.innerHTML="";const a=e.filter((e=>e.fullText.toLowerCase().includes(l)));if(d.classList.toggle("scrollable",a.length>10),0===a.length){const e=document.createElement("div");return e.textContent="לא נמצאו שאלות",e.style.textAlign="center",e.style.opacity="0.7",void d.appendChild(e)}a.forEach((({el:e,text:n,index:o,fullText:i})=>{const l=document.createElement("div");l.textContent=n||`שאלה ${o+1}`,l.title=i;const a=n[0];p(a)?(l.style.direction="rtl",l.style.textAlign="right"):(l.style.direction="ltr",l.style.textAlign="left"),l.addEventListener("click",(t=>{t.preventDefault(),e.scrollIntoView({behavior:"smooth",block:"center"}),e.style.transition="background-color .5s";const n=e.style.backgroundColor;e.style.backgroundColor="yellow",setTimeout((()=>{e.style.backgroundColor=n||""}),1e3)})),d.appendChild(l)}))}c.addEventListener("click",(()=>{t.style.display="none"})),a.addEventListener("click",(()=>{const e=t.classList.toggle("collapsed");a.textContent=e?"+":"-"})),l.addEventListener("click",(()=>{const e=s.classList.toggle("visible");e?s.focus():(s.value="",m())})),s.addEventListener("input",(()=>{m()}));let h=!1,v,g,b;function y(e){if(!h)return;let n=g+(e.clientX-v),o=b+(e.clientY-b);n=Math.max(0,Math.min(window.innerWidth-t.offsetWidth-10,n)),o=Math.max(0,Math.min(window.innerHeight-t.offsetHeight-10,o)),t.style.right="auto",t.style.left=`${n}px`,t.style.top=`${o}px`}n.addEventListener("mousedown",(e=>{h=!0,v=e.clientX,b=e.clientY;const n=t.getBoundingClientRect();g=n.left,b=n.top,e.preventDefault()})),window.addEventListener("mousemove",y),window.addEventListener("mouseup",(()=>{h=!1}));new MutationObserver((()=>{m()})).observe(document.body,{childList:!0,subtree:!0,characterData:!0}),m()})();
(()=>{const e=document.createElement("style");e.textContent="\n #floatingMenu {\n position: fixed;\n top: 100px;\n right: 10px;\n width: 300px;\n max-height: 450px;\n background: rgba(0,0,0,0.7);\n color: white;\n font-family: Arial, sans-serif;\n font-size: 14px;\n border-radius: 6px;\n box-shadow: 0 0 12px black;\n display: flex;\n flex-direction: column;\n user-select: none;\n z-index: 999999;\n overflow: hidden;\n transition: max-height 0.4s ease;\n }\n #floatingMenu.collapsed { max-height: 40px; }\n #floatingMenuHeader {\n padding: 8px 10px;\n background: rgba(0,0,0,0.85);\n cursor: move;\n display: flex;\n justify-content: space-between;\n align-items: center;\n font-weight: bold;\n }\n #floatingMenuTitle { flex-grow: 1; }\n #floatingMenuControls { display: flex; align-items: center; }\n button:not(.keyboard-toggle) {\n cursor: pointer; color: white; margin-left: 6px;\n font-weight: bold; user-select: none;\n background: none; border: none;\n font-size: 16px; line-height: 1; padding: 0;\n display: flex; align-items: center; justify-content: center;\n }\n .keyboard-toggle {\n cursor: pointer; color: white; font-size: 16px;\n line-height: 1; padding: 4px 6px; border-radius: 4px;\n transition: background 0.3s ease; margin-left: 6px;\n }\n .keyboard-toggle.on { background: #2ecc71; }\n .keyboard-toggle.off { background: #7f8c8d; }\n\n #searchInput {\n margin: 3px 10px; padding: 5px 8px; border-radius: 4px;\n border: none; font-size: 14px; width: calc(100% - 20px);\n box-sizing: border-box; direction: rtl;\n color: black;\n }\n #floatingMenuList {\n padding: 5px 10px;\n transition: opacity 0.4s ease;\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n #floatingMenuList.fade { opacity: 0; }\n #floatingMenuList.scrollable {\n overflow-y: auto;\n max-height: 380px;\n }\n #floatingMenuList div {\n padding: 5px 8px;\n border-radius: 4px;\n margin-bottom: 4px;\n background: rgba(255,255,255,0.1);\n cursor: pointer;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow-x: hidden;\n max-width: 100%;\n box-sizing: border-box;\n transition: background 0.25s ease, color 0.25s ease;\n }\n #floatingMenuList div:hover { background: rgba(255,255,255,0.25); }\n #highlight { background: yellow; color: black; font-weight: bold; }\n #floatingMenu.collapsed #searchInput,\n #floatingMenu.collapsed #floatingMenuList {\n opacity: 0; pointer-events: none; height: 0; padding: 0 10px;\n overflow: hidden !important;\n transition: opacity 0.4s ease, height 0.4s ease, padding 0.4s ease, margin 0.4s ease;\n }\n #floatingMenuList .active {\n background: orange !important; color: black !important; transform: scale(1.02);\n }\n ",document.head.appendChild(e);const n=document.createElement("div");n.id="floatingMenu";const t=document.createElement("div");t.id="floatingMenuHeader";const o=document.createElement("div");o.id="floatingMenuTitle",o.textContent="פוסטים";const i=document.createElement("div");i.id="floatingMenuControls";const l=document.createElement("button");l.textContent="-";const r=document.createElement("button");r.textContent="×";const a=document.createElement("button");a.textContent="↕",a.classList.add("keyboard-toggle","on"),i.appendChild(l),i.appendChild(r),t.appendChild(a),t.appendChild(o),t.appendChild(i);const d=document.createElement("input");d.id="searchInput",d.placeholder="חפש פוסטים...";const s=document.createElement("div");s.id="floatingMenuList",n.appendChild(t),n.appendChild(d),n.appendChild(s),document.body.appendChild(n);let c=!0,u=-1,g=null;function p(e){return/[\u0590-\u05FF]/.test(e)}function h(){const e=document.querySelectorAll("main");if(!e.length)return null;let n=null;return e.forEach(e=>{const t=e.getBoundingClientRect();t.height>200&&t.bottom>100&&(n=e)}),n}function f(){const e=h();if(!e)return[];const n=e.querySelectorAll(".whitespace-pre-wrap");return Array.from(n).map((e,n)=>{const t=e.querySelector("a"),o=t?t.textContent.trim():e.textContent.trim();return{element:e,text:o,index:n}})}function x(e){e.style.transition="background-color 1.5s ease",e.style.backgroundColor="yellow",setTimeout(()=>e.style.backgroundColor="",1500)}let m="";function b(e=!1){const n=f(),t=d.value.trim().toLowerCase(),i=n.filter(e=>e.text.toLowerCase().includes(t)),l=JSON.stringify(i.map(e=>e.text));if(l===m)return;m=l,o.textContent=0===i.length?"לא נמצאו פוסטים":"פוסטים";const r=o.textContent.trim().charAt(0);if(o.style.direction=p(r)?"rtl":"ltr",s.innerHTML="",s.classList.toggle("scrollable",i.length>10),0===i.length){const e=document.createElement("div");e.textContent="לא נמצאו פוסטים",e.style.textAlign="center",e.style.opacity="0.7",s.appendChild(e)}else i.forEach(({element:e,text:n},o)=>{const i=document.createElement("div");i.innerHTML=function(e,n){if(!n)return e;const t=new RegExp(`(${o=n,o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");var o;return e.replace(t,'$1')}(n,t),i.style.textAlign=p(n[0])?"right":"left",i.style.direction=p(n[0])?"rtl":"ltr",i.addEventListener("click",()=>{e.scrollIntoView({behavior:"smooth",block:"center"}),x(e),u=o,w(s.querySelectorAll("div"))}),s.appendChild(i)});u=e&&i.length>0?i.length-1:0,w(s.querySelectorAll("div"))}function w(e){e.forEach((e,n)=>{e.classList.toggle("active",n===u),n===u&&e.scrollIntoView({block:"nearest",behavior:"smooth"})})}l.addEventListener("click",()=>n.classList.toggle("collapsed")),r.addEventListener("click",()=>n.remove()),d.addEventListener("input",()=>b()),window.addEventListener("scroll",function(){const e=f(),n=d.value.trim().toLowerCase(),t=e.filter(e=>e.text.toLowerCase().includes(n));if(!t.length)return;const o=window.innerHeight/2;let i=-1,l=1/0;if(t.forEach((e,n)=>{const t=e.element.getBoundingClientRect(),r=Math.abs(t.top+t.height/2-o);r{c=!c,a.classList.toggle("on",c),a.classList.toggle("off",!c)}),window.addEventListener("keydown",e=>{if(!c)return;const n=s.querySelectorAll("div");if(n.length&&("ArrowDown"===e.key&&(e.preventDefault(),u=(u+1)%n.length,w(n)),"ArrowUp"===e.key&&(e.preventDefault(),u=(u-1+n.length)%n.length,w(n)),"Enter"===e.key)){e.preventDefault();const n=f(),t=d.value.trim().toLowerCase(),o=n.filter(e=>e.text.toLowerCase().includes(t));if(o[u]){const e=o[u].element;e.scrollIntoView({behavior:"smooth",block:"center"}),x(e)}}});let v,y,C,k,L=!1;t.addEventListener("mousedown",e=>{L=!0,v=e.clientX,y=e.clientY;const t=n.getBoundingClientRect();C=t.left,k=t.top,e.preventDefault()}),window.addEventListener("mousemove",e=>{if(!L)return;let t=C+(e.clientX-v),o=k+(e.clientY-y);t=Math.max(0,Math.min(t,window.innerWidth-n.offsetWidth)),o=Math.max(0,Math.min(o,window.innerHeight-n.offsetHeight)),n.style.left=t+"px",n.style.top=o+"px",n.style.right="auto"}),window.addEventListener("mouseup",()=>L=!1);new MutationObserver(b).observe(document.body,{childList:!0,subtree:!0}),g=h(),b(!0)})();
אין תגובות:
הוסף רשומת תגובה