// ==UserScript==
// @name DLSite Links++
// @namespace Loli-A-Best
// @include *://boards.4chan.org/*/thread/*
// @include *://boards.4channel.org/*/thread/*
// @include *://8chan.moe/*/res/*
// @version 2.4.3
// @description Persistent nav bar settings link so you can't lock yourself out.
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACUAAAAgCAYAAACVU7GwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAibSURBVFhHjZh1qFVbEMbHbXd3FxZ2K2J3YGFii+0fKoqiGAii2FgoYmB3YyeK3dhd1+7O9eY3nnXeub575X2w7lp7nxWzJr6ZfUXh/tZWrlzpMmfO7MCPHz+sr1ixYoxzY2vZsmWzfseOHbY+JhQvXtxlzJjR5gX6R+LEiUP3H+hEiRs3rvTp08eeGYNv375ZnyZNGkmZMqWNY0Lu3LklRYoUEj9+fEmSJIksX75czp8/H/o1OgoUKCCtW7eWqlWrSpAqVSp74REvXrzQSKRz587y/PlzUc2E3ojcuHFDPn78KJkyZZJKlSqZ4DGhRo0aMmLECPn586fUrVtXtm3bJsWKFbP5jx8/tjmfP3+2vQBnvXnzRrp06SLBoEGDwhpAQG4PeIfkV65ckSAI5MCBA7J582bJnz+/JEqUSMqVKyfDhg2TT58+mSb+RI8ePeTly5dStmxZqV+/vuzcuVPmzJkjefPmtT04q1OnTvLhwwe7eIkSJUyopUuXiowcOdLVqlXLbFmmTBnr9RDXv39/9+DBA1ezZk2zOf707NkzpzdzuXLlciq0UzM61axTjdm6DBkyWI8Pzp8/3/Xt29epCd2ePXvsfaFChWxPj4MHDzrVntu3b589d+zY0eYFX758kcuXL+tY5P3795I2bVpp1KiRpEuXTtRBTf0AzaVPn958o2DBgvZ+ypQposKKXkoSJkwoY8eOtbmYYMaMGXLixAm5e/eu7Nq1S1Rg0wTnDR8+XNq0aSOnT58212jQoIFZiHkgePr0qURFRdkDY+zOIQgFvFPrRawHmACMHj3aegKlYcOGMmHCBOnWrZutxaFpXKJp06ZmanwJ040bN85Mvnv3bvOlO3fuyMCBA+1imD3AP3wEcRME7NWrl00A2B5ERmjJkiWt59ZoD+dXk8rt27elWbNm8uTJE/udC+HIEydOlAEDBtg7BDt37pxMnz5dypcvLxUqVLCgUXeR5MmTS/bs2SXAFN7RAebAsTEjYJIHv4FSpUqZAwP1Odm+fXv4t/Xr14c178GBXBgFDB061OZjLrTogWIwMa4UoMZ8+fKFfhJRZ7Yo84cSfW3btrVQZqPEiRNL48aNTTsgS5Ys8vr167BmFyxYEDa5R/Xq1e3Q8ePHG+UgWO/evWXw4MGhGb+RI0cOi1R+dKpG83rf2rdv73ShjYlE1ZqNq1Wr5vQCTgVxqvJoa5Q+wmMiLvK3SKROndpdunQp9OTcr1+/QiPnNACcOr+LqwQ2Gr+4deuWrv8NIubw4cMWHah806ZNUrhwYTMBWkUbuodoWjD/OXPmjN1cKcVMx7xIEBDMxy/hpSZNmpijE8G4ineZo0ePytq1awW1Ow3laDfzDXz9+tVylprLnvVA165dO6ch765evRqeR1+6dOlo6327d++ezfn+/bv1e/futR4oDbgXL16YxnLmzGmcF+ihlp+SJk2q6/8FN+7ataskSJAgfJupU6fKzJkzhSzQr18/S0/JkiWTxYsX282Jvsig8cCP9HxLK+wxb948o4kqVaoYN7Vo0cIsggxHjhyxNU4nuTp16jh15PDtkB4od7mTJ0+6R48euYsXL7pVq1aZplTVdrv9+/fbfG6pjhxeH9lgffxWk62rV6+e+ZyGv9PIdx06dHCHDh2ys5R03bt37xzk42Bw/ODYsWPh0NYUYPnt7du3dsuzZ8+Kql30cMuJhDMRCKUwhhCHDBkiefLkkfv375v/sA5oGpHjx48bfcBb8BHchBXwZzWr5Uailsi20kU1YGbwAgESMCZkc9RatGhRI1XVkvGJ+pOsWLHCBIKFyQSYb8uWLbbeCwS4ECzPXgQHpt66datVDpzx8OFDUa0bAZPqAqRVR7Tb0zy4HdxDv3DhQlm0aJGow0vz5s2Nq+CxV69eWfSNGjXKLsV8DXmZPHmy7YEQ4NSpU9K9e3dRNzBGz5o1q11OKcbeoTWEQeseZnddhFmNJ3jWDS0S8LMiRYq4li1bOtWW05C1agGoac33NN1YdBKpSi3mf0Sn35vqgKjVMsfWKjk7FS68z6xZs4wB8CcNBke02EJKXA9IknceqmK3ceNGd+3aNXvGwTmA0oUwp1fT2yEIyJhefdX20bRk61QbTmsnW6/at3fMA7xjHxoqs4VECNCU4ebOnWsMPXv2bKeZ3q1evdqpmcJRgiAczEa+VyI0TaERntXZbS57kx2IVi6CYABNsTdz/T7syz6WZlhI4wd1SluEGlG7MrA9A62PrPda8hvSYsOGDRuc1ktm0j+hmcF6r2kaCIgGgPPqQgtXIkInGKkSCBAsjkh0AAgSQsSRfeN3kjcpSs1sNRIBBElyBolbz7P1gOitXbu2jSFnqCdMvFp8hTWlG1oDSK3cYcQJvFPGppWbN2+GRtEB+UamFY8LFy6ERr/P8loChLjV1AhF5BFNWhE6vbW7fv26TfK9x59mU56xPjZwIJVB5IWoz2MCcwIID54A5CHViJXDcAZ8Anz16aFrzbyehzDz34BZqDJ8RQr4CooNAbaFcQEk5ytODvaVofJH+OPCwwsESBP/B5GVJqV0TGDfAAeEjQHUTwpBC6pGq3focXCYmhoL4Jg4ugeaUrOHnmIHl/OgrvIgkKIBoiTr69Caftmabfm+87zCmLCFQ7SccWPGjLE5kcAXqK9iAr9pNNoYIia4qG5jA1TgtEYygTy79+zZ035EKARCMBrcBXzpywerVhb2zgPGjg2TJk1y+lVs/MQHMIBwEdpj2bJl7P27ptZvOct3PMO2+sVhkxAkMrf5tKAJ2eYSeevWrbM09GeUerCXFnd2QUCGoO4HXNbnPLIBWSMO5TA21U9mq8X5OJw2bZqVE/qJLVrimm+p+YxgiU6ilWdKmiVLltg/M4gmvueosfiyJuKoGnhfuXJlq7OoEJR+ZM2aNdKqVSsLJhXGenNw9dWoqCj5B3Bom7hmzZDuAAAAAElFTkSuQmCC
// @grant none
// @run-at document-idle
// ==/UserScript==
class Chan {
CIEN = /(?:(?:http)?\S*ci-en\.dlsite\.com\S*)/gi;
DMMCode = /(?:(?:dmm|www|https?)[^>\s]+)?(?:cid=)?(?:d_|DMM)(\d{6})\/?/gi;
RGCirc = /(?:(?:http|www)?\S*com\S*)?[rv]g(\d{5})(?:\.html)?/gi;
RJCode = /(?:(?:http|www|dlsite)[^>\s]+)?[vr][je]((\d{2})?(\d{3})\d{3})(?:\.html)?/gi;
constructor() {
this.thread = document.querySelector('#divThreads') || document.querySelector('.thread') || document.querySelector('#delform');
this.initSettings();
this.html();
this.css();
this.lewds = this.hgg2d.querySelector('.hgg2d__lewds');
this.codesList = this.hgg2d.querySelector('.hgg2d__codes-list');
this.gridToggle = this.hgg2d.querySelector('.hgg2d__lewdsToggle > a');
this.sidebarSettingsBtn = this.hgg2d.querySelector('.hgg2d__settingsBtn > a');
this.prev = this.addElement('img', document.body, { class: 'hgg2d__follow' });
this.input_previewBar = this.hgg2d__settings.querySelector('.previewBar');
this.input_previewGrid = this.hgg2d__settings.querySelector('.previewGrid');
this.input_showMentions = this.hgg2d__settings.querySelector('.showMentions');
this.input_smoothScrolling = this.hgg2d__settings.querySelector('.smoothScrolling');
this.postRefs = {};
this.initEventListeners();
this.toggle();
this.games = new Set();
document.querySelectorAll('.divMessage, .postMessage').forEach((el) => {
this.work(el);
});
}
addElement(elementName, target = document.body, attributes = {}, where = 'append') {
const element = this.createElement(elementName, attributes);
target[where](element);
return element;
}
addCode(anchor, code, postId) {
let container = this.codesList.querySelector(`[data-code="${code}"]`);
if (!container) {
container = this.createElement('div', { 'data-code': code, class: 'hgg2d__sidebar-item' });
const link = anchor.cloneNode();
link.append(code);
container.appendChild(link);
const refsDiv = this.createElement('div', { class: 'hgg2d__refs-container' });
container.appendChild(refsDiv);
this.codesList.appendChild(container);
}
if (postId) {
if (!this.postRefs[code]) {
this.postRefs[code] = [];
}
if (!this.postRefs[code].includes(postId)) {
this.postRefs[code].push(postId);
const num = postId.replace(/\D/g, '').slice(-3);
const ref = this.createElement('a', {
href: `#p${postId.replace(/\D/g, '')}`,
class: 'hgg2d__post-link no-preview',
title: `Post ${postId}`
});
ref.textContent = ` >>${num}`;
ref.onclick = (e) => {
e.preventDefault();
const targetPost = document.getElementById(postId) || document.getElementById('pc' + postId.replace(/\D/g, '')) || document.getElementById('p' + postId.replace(/\D/g, ''));
if (targetPost) {
targetPost.scrollIntoView();
targetPost.style.transition = 'outline 0.5s';
targetPost.style.outline = '3px dashed #0f0';
setTimeout(() => {
targetPost.style.outline = '';
}, 1500);
}
};
container.querySelector('.hgg2d__refs-container').appendChild(ref);
}
}
}
addPreview(src, link) {
const anchor = this.createElement('a', { href: link, class: 'hgg2d__preview' });
const img = this.createElement('img', { class: 'hgg2d__preview' });
let errors = 0;
img.addEventListener('error', () => {
errors++;
if (errors > 2) {
anchor.remove();
return;
}
if (src.includes('dlsite')) {
src = src.includes('ana') ? src.replace(/ana/g, 'work') : src.replace(/work/g, 'ana');
}
img.src = src;
});
img.src = src;
anchor.appendChild(img);
this.lewds.appendChild(anchor);
}
createRJ(match, code, idx, bucket, postId) {
this.RJCode.lastIndex = 0;
const type = (match.includes('announce') || /[rv]j?a/i.test(match)) ? 'announce' : 'work';
const circleType = match.includes('VJ') ? 'pro' : match.includes('RE') ? 'ecchi-eng' : 'maniax';
const prefix = match.includes('VJ') ? 'VJ' : match.includes('RE') ? 'RE' : 'RJ';
const href = `https://www.dlsite.com/${circleType}/${type}/=/product_id/${prefix}${code}.html`;
const anchor = this.createElement('a', { class: 'hgg2d__code', href });
anchor.append(match);
const bar = `${prefix}${code}`;
this.addCode(anchor, bar, postId);
if (this.games.has(bar)) {
return anchor;
}
this.games.add(bar);
const xcode = (code > 999999) ? code - idx * 1000000 : code;
const adx = (xcode - bucket * 1000 !== 0) ? 1 : 0;
const round = this.padLeft(Number(bucket) % 1000 || Number(bucket) === 0 ? Number(bucket) + adx : Number(bucket), 3);
const pathType = type === 'work' ? 'work' : 'ana';
const circlePathType = circleType === 'pro' ? 'professional' : 'doujin';
const src = `https://img.dlsite.jp/modpub/images2/${pathType}/${circlePathType}/${prefix}${idx || ''}${round}000/${prefix}${code}${pathType === 'ana' ? '_ana' : ''}_img_main.jpg`;
this.addPreview(src, anchor.href);
return anchor;
}
createDMM(match, code, postId) {
this.DMMCode.lastIndex = 0;
const anchor = this.createElement('a', { href: `https://www.dmm.co.jp/dc/doujin/-/detail/=/cid=d_${code}/`, class: 'hgg2d__code' });
const src = `https://doujin-assets.dmm.co.jp/digital/game/d_${code}/d_${code}pr.jpg`;
const bar = `DMM${code}`;
anchor.append(match);
this.addCode(anchor, bar, postId);
if (!this.games.has(bar)) {
this.games.add(bar);
this.addPreview(src, anchor.href);
}
return anchor;
}
createCien(href) {
const a = this.createElement('a', { href });
a.append(href);
return a;
}
createCirc(match, code) {
const [t, p] = match.includes('RG') ? ['maniax', 'RG'] : ['pro', 'VG'];
const href = `https://www.dlsite.com/${t}/circle/profile/=/maker_id/${p}${code}.html`;
const a = this.createElement('a', { href });
a.append(match);
return a;
}
createElement(elementName, attributes = {}) {
const el = document.createElement(elementName);
for (const [k, v] of Object.entries(attributes)) {
el.setAttribute(k, v);
}
return el;
}
css() {
const style = this.addElement('style', document.head);
const probe = this.addElement('div', document.body, { class: 'post reply' });
const { color, backgroundColor } = window.getComputedStyle(probe);
probe.remove();
const css = (`
:root { --backgroundColor: ${backgroundColor}; --color: ${color}; }
.hgg2d { position: fixed; right: 1rem; display: grid; grid-template-columns: 1fr 13.5rem; grid-template-areas: 'lewds codes'; max-width: 65vw; height: 85vh; max-height: 900px; z-index: 1000; box-sizing: border-box; overflow: hidden; }
.hgg2d__codes { display: flex; flex-direction: column; height: 100%; grid-area: codes; padding: 0 10px; background: rgba(0,0,0,0.25); border-left: 1px solid #444; overflow: hidden; }
.hgg2d__sidebar-controls { flex: 0 0 auto; padding: 12px 0; border-bottom: 1px solid #444; margin-bottom: 10px; font-size: 11px; }
.hgg2d__sidebar-controls a { cursor: pointer; display: block; margin-bottom: 6px; color: #0f0 !important; font-weight: bold; text-decoration: none; }
.hgg2d__codes-list { flex: 1 1 auto; overflow-y: auto !important; overflow-x: hidden; padding-bottom: 20px; }
.hgg2d__sidebar-item { display: grid; grid-template-columns: 1fr auto; gap: 5px; align-items: center; margin-bottom: 5px; padding: 2px 4px; border-radius: 3px; border: 1px solid transparent; }
.hgg2d__sidebar-item:hover { background: rgba(255,255,255,0.05); border: 1px solid #555; }
.hgg2d__sidebar-item > a:first-child { font-family: monospace; font-size: 12px; font-weight: bold; color: #0f0 !important; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hgg2d__refs-container { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 3px; max-width: 85px; }
.hgg2d__mentions-hidden .hgg2d__refs-container { display: none !important; }
.hgg2d__post-link { opacity: 0.7; text-decoration: none !important; font-size: 10px; background: rgba(255,255,255,0.1); border-radius: 2px; padding: 0 3px; color: #ccc !important; }
.hgg2d__post-link:hover { opacity: 1; color: #fff !important; background: rgba(0,255,0,0.4); }
.hgg2d__post-highlight { outline: 2px dashed #0f0 !important; box-shadow: 0 0 12px #0f0; }
.hgg2d__follow { display: block; position: fixed; top: 0; z-index: 10001; pointer-events: none; border: 1px solid #fff; max-width: 450px; }
.hgg2d__lewds { display: grid; grid-template-columns: repeat(3, 1fr); grid-area: lewds; align-content: baseline; overflow-y: auto; gap: 2px; }
.hgg2d__preview { display: block; width: 100%; filter: brightness(75%); }
.hgg2d__active, .hgg2d__preview:hover { filter: none; outline: 1px solid #fff; }
.hgg2d__nogrid { width: 0; display: none; }
.hgg2d-hidden { display: none !important; }
.hgg2d__navbarItem { float: right; margin-right: 5px; }
.hgg2d__navbarItem a { cursor: pointer; text-decoration: underline; font-size: 0.9em; }
.hgg2d__settings { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 32rem; padding: 1.5rem; background: var(--backgroundColor); color: var(--color); box-shadow: 0 0 40px rgba(0,0,0,1); z-index: 20000; border: 2px solid #555; }
.hgg2d__matchForm { margin-top: 15px; max-height: 300px; overflow-y: auto; border-top: 1px solid #555; padding-top: 10px; }
.phrase, .url { background: #111; color: #eee; border: 1px solid #444; padding: 2px; }
#hover-notif, .post-hover, .personality-pop { display: none !important; }
`);
style.append(css);
}
html() {
this.hgg2d = this.addElement('section', document.body, { class: 'hgg2d' });
this.hgg2d.innerHTML = (`
<main class="hgg2d__lewds ${this.settings.previewGrid ? '' : 'hgg2d__nogrid'}"></main>
<aside class="hgg2d__codes ${this.settings.showMentions ? '' : 'hgg2d__mentions-hidden'}">
<div class="hgg2d__sidebar-controls">
<div class="hgg2d__lewdsToggle"><a>[${this.settings.previewGrid ? 'Hide' : 'Show'} Lewds]</a></div>
<div class="hgg2d__settingsBtn"><a>[Quicklinks Settings]</a></div>
</div>
<div class="hgg2d__codes-list"></div>
</aside>
`);
this.hgg2d__settings = this.addElement('aside', document.body, { class: 'hgg2d__settings hgg2d-hidden' });
this.hgg2d__settings.innerHTML = (`
<div style="display:flex; justify-content:space-between; margin-bottom:15px"><b>Quicklinks Settings</b><a class="hgg2d__settings-close" style="cursor:pointer; color: red;">[X]</a></div>
<div style="padding: 4px 0;"><label><input type="checkbox" ${this.settings.previewBar ? 'checked' : ''} class="previewBar"> Show Sidebar Panel</label></div>
<div style="padding: 4px 0;"><label><input type="checkbox" ${this.settings.previewGrid ? 'checked' : ''} class="previewGrid"> Show Thumbnail Grid</label></div>
<div style="padding: 4px 0;"><label><input type="checkbox" ${this.settings.showMentions ? 'checked' : ''} class="showMentions"> Show Post Mentions (>>)</label></div>
<div style="padding: 4px 0;"><label><input type="checkbox" ${this.settings.smoothScrolling ? 'checked' : ''} class="smoothScrolling"> Smoothscrolling</label></div>
<div class="hgg2d__matchForm">
<b>Text replacements:</b>
<div style="display:grid; grid-template-columns: 1fr 1fr 60px; gap:5px; margin-bottom:10px;">
<input class="phrase" placeholder="trigger text">
<input class="url" placeholder="URL/ID">
<button class="add-btn">Add</button>
</div>
<div class="hgg2d__match-list"></div>
</div>
`);
this.settings.matches.forEach((m) => {
this.createMatchUI(m[0], m[1]);
});
// Persistent Settings Link in the Nav Bar
document.querySelectorAll('.navLinks.desktop').forEach((nav) => {
const container = this.addElement('div', nav, { class: 'hgg2d__navbarItem' });
const link = this.addElement('a', container);
link.textContent = '[quicklinks settings]';
link.onclick = () => {
this.hgg2d__settings.classList.toggle('hgg2d-hidden');
};
});
}
createMatchUI(phrase, url) {
const list = this.hgg2d__settings.querySelector('.hgg2d__match-list');
const div = this.addElement('div', list, { style: 'display:grid; grid-template-columns: 1fr 1fr 60px; gap:5px; margin-bottom:5px;' });
div.innerHTML = `<input disabled value="${phrase}" class="phrase"><input disabled value="${url}" class="url"><button class="rem-btn">Rem</button>`;
div.querySelector('.rem-btn').onclick = () => {
this.settings.matches = this.settings.matches.filter((m) => {
return m[0] !== phrase;
});
div.remove();
localStorage.setItem('hgg2d', JSON.stringify(this.settings));
};
}
initEventListeners() {
new MutationObserver((m) => {
m.forEach((x) => {
x.addedNodes.forEach((n) => {
this.work(n);
});
});
}).observe(this.thread, { childList: true });
document.body.addEventListener('mouseover', this.over, false);
document.body.addEventListener('mouseout', this.out, false);
this.hgg2d__settings.querySelector('.hgg2d__settings-close').onclick = () => {
this.hgg2d__settings.classList.add('hgg2d-hidden');
};
this.sidebarSettingsBtn.onclick = () => {
this.hgg2d__settings.classList.toggle('hgg2d-hidden');
};
this.hgg2d__settings.querySelector('.add-btn').onclick = () => {
const p = this.hgg2d__settings.querySelector('.phrase');
const u = this.hgg2d__settings.querySelector('.url');
if (p.value && u.value) {
this.settings.matches.push([p.value, u.value]);
this.createMatchUI(p.value, u.value);
localStorage.setItem('hgg2d', JSON.stringify(this.settings));
p.value = '';
u.value = '';
}
};
this.input_previewBar.onchange = (e) => {
this.settings.previewBar = e.target.checked;
this.toggle();
};
this.input_previewGrid.onchange = (e) => {
this.settings.previewGrid = e.target.checked;
this.lewds.classList.toggle('hgg2d__nogrid', !e.target.checked);
};
this.input_showMentions.onchange = (e) => {
this.settings.showMentions = e.target.checked;
this.hgg2d.querySelector('.hgg2d__codes').classList.toggle('hgg2d__mentions-hidden', !e.target.checked);
localStorage.setItem('hgg2d', JSON.stringify(this.settings));
};
this.gridToggle.onclick = () => {
this.settings.previewGrid = !this.settings.previewGrid;
this.lewds.classList.toggle('hgg2d__nogrid', !this.settings.previewGrid);
this.gridToggle.textContent = this.settings.previewGrid ? '[Hide Lewds]' : '[Show Lewds]';
};
window.addEventListener('scroll', () => {
const rect = this.thread.getBoundingClientRect();
const topThreshold = rect.top + window.scrollY;
this.hgg2d.style.top = Math.max(50, (topThreshold + 50) - window.scrollY) + 'px';
});
}
initSettings() {
const def = { previewBar: true, previewGrid: true, showMentions: true, smoothScrolling: true, matches: [] };
this.settings = JSON.parse(localStorage.getItem('hgg2d')) || def;
}
toggle() {
this.hgg2d.classList.toggle('hgg2d-hidden', !this.settings.previewBar);
localStorage.setItem('hgg2d', JSON.stringify(this.settings));
}
matchText(node, regex, callback) {
let child = node.firstChild;
while (child) {
if (child.nodeType === 1 && !['SCRIPT', 'STYLE', 'A'].includes(child.tagName)) {
this.matchText(child, regex, callback);
} else if (child.nodeType === 3) {
let match;
const currentData = child.data;
regex.lastIndex = 0;
if ((match = regex.exec(currentData)) !== null) {
const matchText = match[0];
const offset = match.index;
const next = child.splitText(offset);
next.data = next.data.substr(matchText.length);
const groups = match.slice(1);
const anchor = callback.apply(this, [matchText].concat(groups));
child.parentNode.insertBefore(anchor, next);
child = next;
regex.lastIndex = 0;
}
}
child = child.nextSibling;
}
}
over = (e) => {
const target = e.target.closest('.hgg2d__code, .hgg2d__sidebar-item');
if (!target) {
return;
}
const link = target.tagName === 'A' ? target : target.querySelector('a');
const m = link ? link.href.match(/([RV][JE]\d+|d_\d+)/) : null;
if (!m) {
return;
}
const code = m[0].replace('d_', 'DMM');
if (this.postRefs[code]) {
this.postRefs[code].forEach((id) => {
const el = document.getElementById(id) || document.getElementById('pc' + id.replace(/\D/g, '')) || document.getElementById('p' + id.replace(/\D/g, ''));
if (el) {
el.classList.add('hgg2d__post-highlight');
}
});
}
const img = this.lewds.querySelector(`img[src*="${m[0]}"]`);
if (img) {
if (this.settings.previewGrid) {
img.classList.add('hgg2d__active');
img.scrollIntoView({ behavior: 'smooth', block: 'center' });
} else {
this.prev.src = img.src;
this.prev.style.visibility = 'visible';
const r = target.getBoundingClientRect();
this.prev.style.top = (r.top > window.innerHeight / 2 ? r.top - 420 : r.bottom + 10) + 'px';
this.prev.style.left = (r.left > window.innerWidth / 2 ? r.left - 460 : r.right + 10) + 'px';
}
}
};
out = () => {
document.querySelectorAll('.hgg2d__post-highlight').forEach((e) => {
e.classList.remove('hgg2d__post-highlight');
});
document.querySelectorAll('.hgg2d__active').forEach((e) => {
e.classList.remove('hgg2d__active');
});
this.prev.style.visibility = 'hidden';
};
padLeft(s, l) {
return String(s).padStart(l, '0');
}
work(node) {
if (!node || node.nodeType !== 1) {
return;
}
const post = node.closest('.postContainer, .post');
const postId = post ? post.id : null;
node.querySelectorAll('wbr').forEach((w) => {
w.remove();
});
node.normalize();
this.matchText(node, this.CIEN, (h) => {
return this.createCien(h);
});
this.matchText(node, this.DMMCode, (m, c) => {
return this.createDMM(m, c, postId);
});
this.matchText(node, this.RGCirc, (m, c) => {
return this.createCirc(m, c);
});
this.matchText(node, this.RJCode, (m, c, i, b) => {
return this.createRJ(m, c, i, b, postId);
});
}
}
new Chan();