original-poster

Add an indicator to all messages by the thread's original poster

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

// ==UserScript==
// @name        original-poster
// @description Add an indicator to all messages by the thread's original poster
// @namespace   https://cfillion.ca
// @version     1.2
// @author      cfillion
// @license     GPL-3.0-or-later
// @include     https://forum.cockos.com/showthread.php*
// ==/UserScript==

function getPosters(doc)
{
  return doc.querySelectorAll('.bigusername');
}

let label = document.createElement('span');
label.appendChild(document.createTextNode('OP'));
label.title = 'Original poster';
label.style = `
  background-color: #12768c;
  border-radius: 3px;
  color: white;
  cursor: default;
  font-size: 12px;
  font-weight: bold;
  margin-left: 5px;
  padding-left: 4px;
  padding-right: 4px;
`;

(async() => {
  const posters = getPosters(document);
  let op = posters[0];

  const threadId = document.querySelector('form input[name=searchthreadid]');
  const params = new URLSearchParams(window.location.search);
  if(threadId && (params.get('page') > 1 || params.has('p'))) {
    let response = await fetch(new URL(`showthread.php?t=${threadId.value}`, window.location.href));
    const html = await response.text();
    let parser = new DOMParser();
    let firstPage = parser.parseFromString(html, "text/html");
    op = getPosters(firstPage)[0];
  }

  for(const poster of posters) {
    if(poster.href == op.href)
      poster.parentNode.insertBefore(label.cloneNode(true), poster.nextSibling);
  }
})();