douban marked

douban markdown

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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://greasyfork.org/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);
})();