DNA_weekly_helper

DNA_weekly_cp

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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 यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         DNA_weekly_helper
// @namespace    dgistdna.com
// @version      2024-12-29
// @description  DNA_weekly_cp
// @author       You
// @match        https://stuecm.dgist.ac.kr/s/potal_board/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant GM_setClipboard
// ==/UserScript==

// (function() {
//     'use strict';

//     // Your code here...

// })();

function extractPathAndQuery(url) {
  // Find the position of the third slash (/) which marks the end of the domain
  var domainEndIndex = url.indexOf("/", url.indexOf("//") + 2);

  // Extract the path and query string from the URL
  var pathAndQuery = url.substring(domainEndIndex);

  return pathAndQuery;
}

function copyLink2() {
  /*$("#copyLinkText").val("test111");

  var $temp = document.getElementById('copyLinkText');
  $temp.select();*/

  var domain = "https://ecm.dgist.ac.kr";
  var domain_stu = "https://stuecm.dgist.ac.kr";
  var url = extractPathAndQuery(document.URL);
  var title='';
  var titles = [];
  var elem1 = document.querySelector(
    "#content > table > tbody > tr:nth-child(1) > th > strong > b"
  );
  if (elem1 != null) {
     title = elem1.innerText;
     titles = title.split("\n");
  } else {
    var elem2 = document.querySelector(
      "#content > table > tbody > tr:nth-child(1) > th > strong"
    );
    if (elem2 != null) {
       title = elem2.innerHTML;
       titles=title.split("<br>");
       titles=titles.map(function (x) {return x.trim()});
    } else {
        return;
    }
  }


//   alert(title);

  var copyLinkHtml;
  if (titles.length == 1) {
    copyLinkHtml =
      titles[0] +
      " " +
      "<a href='" +
      domain_stu +
      url +
      "'>[학생]</a> <a href='" +
      domain +
      url +
      "'> [교직원]</a>";
  } else {
    copyLinkHtml =
      titles[0] +
      " " +
      "<a href='" +
      domain_stu +
      url +
      "'>[학생]</a> <a href='" +
      domain +
      url +
      "'> [교직원]</a><br>" +
      titles[1] +
      " " +
      "<a href='" +
      domain_stu +
      url +
      "'>[student]</a> <a href='" +
      domain +
      url +
      "'> [employee]</a>";
  }
  navigator.clipboard
    .write([
      new ClipboardItem({
        "text/html": new Blob([copyLinkHtml], { type: "text/html" }),
        "text/plain": new Blob([copyLinkHtml], { type: "text/plain" }),
      }),
    ])
    .then(function () {
    //   alert("복사 되었습니다.");
    })
    .catch(function (error) {
      //   console.error("Copy failed", error);
      alert("Copy failed", error);
    });
  //   //alert("my 복사");
}
copyLink2();
// //GM_setClipboard('dwd','html')
// alert("end");
// console.log("end");