douban marked

douban markdown

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!)

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!)

// ==UserScript==
// @name         douban marked
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  douban markdown
// @author       haidao
// @include      https://*.douban.com/*
// @grant        none
// @require      https://cdnjs.cloudflare.com/ajax/libs/markdown-it/7.0.0/markdown-it.min.js
// @require      https://greatest.deepsurf.us/scripts/21647-markdown-it-footnote/code/markdown-it-footnote.js?version=137863
// ==/UserScript==

(function() {
  // douban 会自动添加a标签,去掉
  $('#link-report span a').each(function(i, e){
    var c=$(e).text();
    $(e).replaceWith(c);
  });
  var content = $('#link-report span').html();
  // blockquote
  content = content.replace(/<br>/g,'\n').replace(/&gt;/g,'>');
  var mdf = window.markdownitFootnote;
  var md = window.markdownit().use(mdf);
  var marked_content = md.render(content);
  $('#link-report span').html(marked_content);

  // mathjax
  var head = document.getElementsByTagName("head")[0], script;
  script = document.createElement("script");
  script.type = "text/x-mathjax-config";
  script[(window.opera ? "innerHTML" : "text")] =
    "MathJax.Hub.Config({\n" +
    "  tex2jax: { inlineMath: [['$','$'], ['\\\\(','\\\\)']] }\n" +
    "});";
  head.appendChild(script);
  script = document.createElement("script");
  script.type = "text/javascript";
  script.src  = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
  head.appendChild(script);
})();