HSPTV! Forum Script

HSPTV!掲示板用のUserScriptです。

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Advertisement:

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

Advertisement:

// ==UserScript==
// @name         HSPTV! Forum Script
// @version      1.1.2
// @description  HSPTV!掲示板用のUserScriptです。
// @author       prince
// @homepage     http://prince0203.github.io/
// @copyright    (c)prince 2016
// @namespace    io.github.prince0203
// @icon         http://hsp.tv/favicon.ico
// @match        http://hsp.tv/play/pforum.php?mode=*
// @run-at       document-end
// @grant        none
// @require      https://code.jquery.com/jquery-3.1.1.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.10.0/highlight.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.10.0/languages/hsp.min.js
// ==/UserScript==

// 設定
var option = {
  // 長いソースがあるときでも表示が崩れないようにする(デフォルト: true)
  "fixDisplay": true,

  // 投稿にHPがない場合「HP」画像を削除する(デフォルト: true)
  "noHpImage": true,

  // 投稿者のIPアドレスを表示する(デフォルト: true)
  "ip": true,

  // ソースコードをhighlight.jsを使用して色分けする(デフォルト: true)
  "highlight": true,

  // highlight.jsのテーマ https://highlightjs.org/static/demo/ を参照(デフォルト: Dark)
  "highlightTheme": "Dark"
};

// 長いソースがあるときでも表示が崩れないようにする
if (option.fixDisplay) {
  $('table[background^="../images/bbs/back"]').css('table-layout', 'fixed');
  $('pre > br').remove();
  if(!option.highlight) {
    $('pre').css({
      'border-radius': '5px',
      'box-shadow': '0px 0px 3px 2px rgba(0, 0, 0, 0.15)',
      'margin': '10px',
      'padding': '10px',
      'color': '#5A5A5A',
      'background-color': '#F8F8F8',
      'overflow': 'auto'
    });
  }
}

// HPがない場合画像を削除
if (option.noHpImage) {
  $('div#info')
    .append('<br>')
    .children('img[src="../images/bbs/icon_hp_g_no.gif"], img[src="../images/bbs/icon_hp_no.gif"]')
    .remove();
}

// IPアドレスを表示
if (option.ip) {
  var comments = document.body.innerHTML.match(/<!--.*-->/g);
  $(comments).each(function(index) {
    comments[index] = this.substr(4);
    comments[index] = comments[index].substr(0, (comments[index].length - 3));
  });

  $('div#info').each(function(index) {
    $(this).append(comments[index]);
  });
}

// highlight.js
if (option.highlight) {
  $('pre')
    .css('margin', '0px')
    .wrapInner('<code/>')
    .children('code')
    .css({
    'margin': '10px',
    'padding': '10px',
    'border-radius': '8px',
    'box-shadow': '0px 0px 3px 2px rgba(0, 0, 0, 0.15)',
    'font-size': '1.2em'
  })
    .each(function() {
      $(this).text($(this).text().substr(1));
    });
  $('head').append('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.10.0/styles/' + option.highlightTheme.toLowerCase().replace(/ /g, '-') + '.min.css">');

  hljs.initHighlightingOnLoad();
}