Greasy Fork is available in English.

BillMonk Image Adder

Creates images from first comment, if its format is img:http://...

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           BillMonk Image Adder
// @namespace      http://www.arthaey.com/
// @description    Creates images from first comment, if its format is img:http://...
// @include        https://www.billmonk.com/receipt/*
//
// Backed up from http://userscripts.org/scripts/review/6706
// Last updated on 2006-12-09
// @version 0.0.1.20140612212410
// ==/UserScript==

// TODO
//  - look at all comments and add multiple images if necessary
//  - make it a user preference whether image is added at top or in sidebar

window.addEventListener("load", function() {
   // check that elements are where we expect them to be
   var sharedImg = document.getElementsByTagName("img")[7];
   if (!sharedImg) return;

   /*
   var sidebar = getElementsByClassName("sidebar_box", "table")[0];
   if (!sidebar) return;
   */

   var commentDiv = document.getElementById("comments");
   if (!commentDiv) return;

   // if Linkify has already run, then it will be a span with an anchor
   var src;
   var comment = commentDiv.getElementsByTagName("span")[0];
   if (comment && comment.childNodes[0].nodeValue == "img:") {
      src = comment.childNodes[1].href;
   }
   // otherwise, it's just plain text
   else {
      comment = commentDiv.getElementsByTagName("i")[0];
      if (!comment) return;

      var regex = new RegExp("^img:(http://.+)$");
      src = comment.childNodes[0].nodeValue;
      if (!regex.test(src)) return;
      src = regex.exec(src)[1];
   }
   if (!src) return;

   var img = document.createElement("img");
   img.style.cssFloat = "left";
   img.src = src;

   // insert before "Shared Receipt" image
   sharedImg.parentNode.insertBefore(img, sharedImg);

   /*
   img.style.marginTop = "1em";
   // insert after "Use your cell phone" box in sidebar
   sidebar.parentNode.insertBefore(img, sidebar.nextSibling);
   */
}, true);

/*
function getElementsByClassName(clsName,htmltag){ 
  var arr = new Array(); 
  var elems = document.getElementsByTagName(htmltag);
  for ( var cls, i = 0; ( elem = elems[i] ); i++ ){
    if ( elem.className == clsName ){
      arr[arr.length] = elem;
    }
  }
  return arr;
}
*/