SDN Forum Araçlar

SDN Forum deneyimini iyilestiren ozellikler

اعتبارا من 20-01-2023. شاهد أحدث إصدار.

// ==UserScript==
// @name         SDN Forum Araçlar
// @version      1.6.3
// @description  SDN Forum deneyimini iyilestiren ozellikler
// @author       Çınar Yılmaz <[email protected]>
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @match        https://forum.shiftdelete.net/*
// @icon         https://forum.shiftdelete.net/favicon.ico
// @license      GPLv3
// @grant        GM_setValue
// @grant        GM_getValue
// @namespace    sdn-utils
// ==/UserScript==
var $ = window.jQuery;

$('<style>').text(`.p-navEl-link[data-nav-id="sdnutils"]::before {
  content: "\\f013";
}`).appendTo(document.head)

if (GM_getValue('gozardiguzellestir', 'none') === 'none') {
  GM_setValue('gozardiguzellestir', 'true');
}

if (GM_getValue('dersmodu', 'none') === 'none') {
  GM_setValue('dersmodu', 'false');
}

if (GM_getValue('sabahaksam', 'none') === 'none') {
  GM_setValue('sabahaksam', 'false');
}

if (GM_getValue('sabahsaati', 'none') === 'none') {
  GM_setValue('sabahsaati', 6);
}

if (GM_getValue('aksamsaati', 'none') === 'none') {
  GM_setValue('aksamsaati', 20);
}

if (GM_getValue('videosil', 'none') === 'none') {
  GM_setValue('videosil', 'false');
}

$.ajaxSetup({
  async: false
});

var scriptElem = document.createElement('script');
scriptElem.innerHTML = 'function copy(text) {var tmp = document.createElement("input");tmp.value = text;document.body.appendChild(tmp);tmp.select();document.execCommand("copy");document.body.removeChild(tmp);alert("Kopyalandı!");}';
document.body.appendChild(scriptElem);

// URL: https://forum.shiftdelete.net/hesap/hesap-detaylari/ignored
// Kara listede bulunan üye sayısını gösterir. Metin olarak indirme imkanı sunar.
if (window.location.pathname == "/hesap/engellenenler") {
  var blocked = $("a:contains('Yok sayma')").length;
  let userstext = "";
  $("h3.contentRow-header a.username").each(function(){
    userstext += "ID: " + $(this).attr("data-user-id") + ", Username: " + $(this).text() + " | ";
  });

  $(".p-title-value").html("Kara Liste (" + blocked + " üye) <span onclick=\"copy('" + userstext + "')\" style=\"color: #70abcb;\">Listeyi metin olarak kopyala</a>");
}

// URL: https://forum.shiftdelete.net/*
// 'Bu kullanıcının içeriğini görmezden geliyorsunuz' kutularını daha az göze batan hale getirir.
if (GM_getValue('gozardiguzellestir') === "true") {
  $('.messageNotice--ignored').css({"padding-left": "10px", "margin-top": "5px", "margin-bottom": "5px"});
  $('.messageNotice--ignored').addClass("bbCodeBlock");
  $('.messageNotice--ignored').removeClass("messageNotice--ignored messageNotice");
}

// URL: https://forum.shiftdelete.net/*
// SDN Araçlar Ayarları linkini menüye ekler
$('ul.p-nav-list > li:nth-child(1)').after(`<li class="navsdnutils">
<div class="p-navEl ">
<a href="/hesap/hesap-detaylari?sdn-utils" class="p-navEl-link " data-xf-key="7" data-nav-id="sdnutils">SDN Araçlar Ayarları</a>
</div>
</li>
`);

// URL: https://forum.shiftdelete.net/hesap/hesap-detaylari?sdn-utils
// SDN Araçlar Ayarları
var url = new URL(window.location.href);
if (window.location.pathname == "/hesap/hesap-detaylari" && url.searchParams.has('sdn-utils')) {
  $('.p-body-sideNav, .p-body-sideNavCol, .blockMessage, .formSubmitRow, .block-formSectionHeader').remove();
  var cont = $('.block-body')[0].children;
  while(cont.length > 0) {
    cont[0].remove();
  }
  $('.block-body')[1].remove();
  $('.p-title-value').text('SDN Forum Araçlar Ayarları');
  $('span:contains("Hesabınız")').parent().attr('href', 'https://forum.shiftdelete.net/hesap/hesap-detaylari?sdn-utils');
  $('span:contains("Hesabınız")').text('SDN Araçlar');
  var gozardiguzellestir_sel = "";
  if (GM_getValue('gozardiguzellestir') === "true") {
    gozardiguzellestir_sel = " checked";
  }
  var dersmodu_sel = "";
  if (GM_getValue('dersmodu') === "true") {
    dersmodu_sel = " checked";
  }
  var sabahaksam_sel = "";
  if (GM_getValue('sabahaksam') === "true") {
    sabahaksam_sel = " checked";
  }
  var videosil_sel = "";
  if (GM_getValue('videosil') === "true") {
    videosil_sel = " checked";
  }
  var sabahsaati = GM_getValue('sabahsaati');
  var aksamsaati = GM_getValue('aksamsaati');

  var versionwarn = "";
  $.getJSON("https://greasyfork.org/en/scripts/458497-technopat-sosyal-ara%C3%A7lar.json", function(data){
    if (data.version !== GM.info.script.version){
      versionwarn = "<a href=\"https://greasyfork.org/en/scripts/458497\" class=\"button--link button\"><span class=\"button-text\">Guncelle (" + data.version + ")</span></a>";
    }
  });
  $('.block-body')[0].innerHTML = `<dl class="formRow">
<dt>
<div class="formRow-labelWrapper">
<label class="formRow-label">Mod seçenekleri</label>
</div>
</dt><dd>
<ul class="inputChoices" role="group">
<li class="inputChoices-choice">
<label class="iconic">
<input type="checkbox" name="gozardiguzellestir" value="1"${gozardiguzellestir_sel}>
<i aria-hidden="true"></i>
<span class="iconic-label">Göz ardı uyarılarını sadeleştir</span>
</label>
</li><li class="inputChoices-choice">
<label class="iconic">
<input type="checkbox" name="dersmodu" value="1"${dersmodu_sel}>
<i aria-hidden="true"></i>
<span class="iconic-label">Ders modu</span>
</label>
</li>
<li class="inputChoices-choice">
<label class="iconic">
<input type="checkbox" name="sabahaksam" value="1"${sabahaksam_sel}>
<i aria-hidden="true"></i>
<span class="iconic-label">Sabah ve akşam farklı tema göster</span>
</label>
</li>
<li class="inputChoices-choice">
<label class="iconic">
<input type="checkbox" name="videosil" value="1"${videosil_sel}>
<i aria-hidden="true"></i>
<span class="iconic-label">Anasayfadaki videoyu sil</span>
</label>
</li>
</ul>
</dd>
</dl>
<dl class="formRow">
<dt>
<div class="formRow-labelWrapper">
<label class="formRow-label">Sabah saati</label>
</div>
</dt><dd>
<input type="number" class="input" name="sabahsaati" value="${sabahsaati}" maxlength="50" placeholder="Sabah Saati">
</dd>
</dl>
<dl class="formRow">
<dt>
<div class="formRow-labelWrapper">
<label class="formRow-label">Akşam saati</label>
</div>
</dt><dd>
<input type="number" class="input" name="aksamsaati" value="${aksamsaati}" maxlength="50" placeholder="Akşam Saati">
</dd>
</dl>
<hr class="formRowSep">
<dl class="formRow">
<dt>
<div class="formRow-labelWrapper">
<label class="formRow-label">SDN Araçlar versiyonu</label>
</div>
</dt>
<dd>
${GM.info.script.version}
${versionwarn}
</dd>
</dl>
<dl class="formRow">
<dt>
<div class="formRow-labelWrapper">
<label class="formRow-label">${GM.info.scriptHandler} versiyonu</label>
</div>
</dt>
<dd>${GM.info.version}</dd>
</dl>
<dl class="formRow formSubmitRow formSubmitRow--sticky" data-xf-init="form-submit-row" style="height: 42.1875px;">
<dt></dt>
<dd>
<div class="formSubmitRow-main" style="">
<div class="formSubmitRow-bar"></div>
<div class="formSubmitRow-controls"><button type="submit" class="button--primary button button--icon button--icon--save"><span class="button-text">Kaydet</span></button></div>
</div>
</dd>
</dl>`;
  $('title').text("SDN Araçlar Ayarları | SDN Forum");
  $('.button--icon--save').click(function(){
    if ($('[name="gozardiguzellestir"]').is(':checked')) {
      GM_setValue('gozardiguzellestir', "true")
    } else {
      GM_setValue('gozardiguzellestir', "false")
    }
    if ($('[name="dersmodu"]').is(':checked')) {
      GM_setValue('dersmodu', "true")
    } else {
      GM_setValue('dersmodu', "false")
    }
    if ($('[name="sabahaksam"]').is(':checked')) {
      GM_setValue('sabahaksam', "true")
    } else {
      GM_setValue('sabahaksam', "false")
    }
    if ($('[name="sabahaksam"]').is(':checked')) {
      GM_setValue('sabahaksam', "true")
    } else {
      GM_setValue('sabahaksam', "false")
    }
    if ($('[name="videosil"]').is(':checked')) {
      GM_setValue('videosil', "true")
    } else {
      GM_setValue('videosil', "false")
    }
    GM_setValue('sabahsaati', $('[name="sabahsaati"]').val())
    GM_setValue('aksamsaati', $('[name="aksamsaati"]').val())
    location.reload();
  });
  $('form.block').attr({
      action: '/hesap/hesap-detaylari?sdn-utils',
      method: 'get'
  });
}

// URL: https://forum.shiftdelete.net/* -x https://forum.shiftdelete.net/hesap/hesap-detaylari?sdn-utils
// Ders modu
if (!(window.location.pathname == "/hesap/hesap-detaylari" && url.searchParams.has('sdn-utils')) && GM_getValue('dersmodu') === "true") {
  $('head *').remove();
  $('head').html('<meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=Edge"><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"><title>Ders modu aktif | SDN Forum</title><meta name="theme-color" content="#1e1e1e"><style>html{font:15px / 1.4 sans-serif;font-family:\'Segoe UI\',\'Helvetica Neue\',Helvetica,Roboto,Oxygen,Ubuntu,Cantarell,\'Fira Sans\',\'Droid Sans\',sans-serif;font-weight:400;color:#9aa0a6;margin:0;padding:0;word-wrap:break-word;background-color:#202124}body{max-width:1300px;padding:0 10px;margin:0 auto}a{color:#e2e4e8;text-decoration:none}a:hover{color:#fff;text-decoration:underline}.p-offline-header{padding:0;font-size:22px;font-weight:400}.p-offline-main{margin-bottom:20px;padding:10px 12px;color:#9aa0a6;background:#292a2d;border-width:1px;border-style:solid;border-top-color:#39393b;border-right-color:#39393b;border-bottom-color:#464648;border-left-color:#39393b;box-shadow:2px 2px 2px rgba(0,0,0,0.04);border-radius:4px;background-image:none}.p-offline-main:before,.p-offline-main:after{content:" ";display:table}.p-offline-main:after{clear:both}.button,a.button{display:inline-block;display:inline-flex;align-items:center;justify-content:center;text-decoration:none;cursor:pointer;border:1px solid transparent;white-space:nowrap;-webkit-transition: background-color .075s ease, border-color .075s ease, color .075s ease;transition: background-color .075s ease, border-color .075s ease, color .075s ease;font-size:13px;border-radius:4px;padding-top:8px;padding-right:10px;padding-bottom:8px;padding-left:10px;text-align:center;color:#fff;background:#333435;border-color:#262728 #404142 #404142 #262728}.button.button--splitTrigger>.button-text,a.button.button--splitTrigger>.button-text{border-right-color:#404142}.button.button--splitTrigger>.button-menu,a.button.button--splitTrigger>.button-menu{border-left-color:#262728}.button:not(.button--splitTrigger):hover,a.button:not(.button--splitTrigger):hover,.button.button--splitTrigger>.button-text:hover,a.button.button--splitTrigger>.button-text:hover,.button.button--splitTrigger>.button-menu:hover,a.button.button--splitTrigger>.button-menu:hover,.button:not(.button--splitTrigger):focus,a.button:not(.button--splitTrigger):focus,.button.button--splitTrigger>.button-text:focus,a.button.button--splitTrigger>.button-text:focus,.button.button--splitTrigger>.button-menu:focus,a.button.button--splitTrigger>.button-menu:focus,.button:not(.button--splitTrigger):active,a.button:not(.button--splitTrigger):active,.button.button--splitTrigger>.button-text:active,a.button.button--splitTrigger>.button-text:active,.button.button--splitTrigger>.button-menu:active,a.button.button--splitTrigger>.button-menu:active{background-color:#47484a}</style>');
  $('body *').remove();
  $('body').html('<h1 class="p-offline-header">SDN Forum</h1><div class="p-offline-main">Ders Modu aktif. SDN Forum\'ı Ders Modu aktifken kullanamazsınız.<br><a href="/hesap/hesap-detaylari?sdn-utils" class="button">SDN Araclar Ayarlari</a></div>');
}

// URL: https://forum.shiftdelete.net/*
// Footer'a SDN Araçlar yazısı
$('.xb-footer-block p').append('<br /><br /><a href="https://greasyfork.org/en/scripts/458497" class="u-concealed" dir="ltr" target="_blank" rel="sponsored noopener">SDN Araçlar ' + GM.info.script.version + '</a>')

// URL: https://forum.shiftdelete.net/*
// Sabah aydınlık, akşam karanlık tema.
if (GM_getValue('sabahaksam') === "true") {
  const saat = new Date().getHours();
  const sabah = saat > parseInt(GM_getValue("sabahsaati")) && saat < parseInt(GM_getValue("aksamsaati"));
  if (sabah) {
    if ($("html").css("color") == "rgb(154, 160, 166)") {
      $.get("https://forum.shiftdelete.net/diger/style", function(data){
        var njq = $('<div/>').html(data);
        window.location.href = njq.find("a:contains('New (Day)').menu-linkRow").attr("href").split('&')[0];
      });
    }
  } else {
    if ($("html").css("color") == "rgb(29, 29, 29)") {
      $.get("https://forum.shiftdelete.net/diger/style", function(data){
        var njq = $('<div/>').html(data);
        window.location.href = njq.find("a:contains('New (Night)').menu-linkRow").attr("href");
      });
    }
  }
}

// URL: https://forum.shiftdelete.net/*
// Anasayfadaki öne çıkarılan SDN videosunu kaldırır
// Ekstra not: Kod diğer sayfalarda hiçbir şey yapmayacağı için URL özel olarak ayarlanmadı
if (GM_getValue('videosil') === "true") {
  $('.reklamyoutube-container').remove();
}