Skip to content

Instantly share code, notes, and snippets.

@zuzu
Created April 5, 2009 10:44
Show Gist options
  • Save zuzu/90425 to your computer and use it in GitHub Desktop.
Save zuzu/90425 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name SBM Comments Viewer for chrome
// @namespace http://zuzu-service.net/
// @description Show social bookmark's comments at the bottom of chrome.
// @version 0.0.1
// @include http://*
// @exclude http://reader.livedoor.com/reader/*
// @exclude http://www.google.com/search?*
// author: zuzu( http://d.hatena.ne.jp/zuzu_sion/ )
// original author: tyoro( http://tyoro.orz.ne.jp/ )
// original script : http://white.s151.xrea.com/wiki/index.php?script/SBMCommentsViewer
// by http://white.s151.xrea.com/blog/
// ==/UserScript==
/*
Last Modified: 2007.11.01
Copyright (C) 2006-2007 shiro
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name of the author may not be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
var SBMCommentsViewer = function() {
var forfilter = function(arr,callback) {
var _arr = [];
for(var i=0, len = arr.length; i < len; i++) {
try {
if (callback(arr[i],i)) _arr.push(arr[i]);
} catch (e) {
throw e;
}
}
return _arr;
};
// --------------------------------------------------------------
// Shortcut key
// --------------------------------------------------------------
// C -- control
// S -- shift
// A -- alt
var BIND_KEY = 'S-c';
// --------------------------------------------------------------
// max count (each sbm)
// --------------------------------------------------------------
var MAX_GET_COUNT = 100;
// --------------------------------------------------------------
// ignore user
// --------------------------------------------------------------
var ignore_hatena = [];
var ignore_delicious = [];
var ignore_livedoor = [];
var ignore_buzzurl = [];
var ignore_pookmark = [];
var ignore_ldr = [];
// --------------------------------------------------------------
// mouse
// --------------------------------------------------------------
// mouseover,click,dblclick etc
var mouse_event_show = 'click';
// --------------------------------------------------------------
// CSS
// --------------------------------------------------------------
var font_css = "font-size:100%; color:#333333;";
var button_font_css = "font-size:100%; color:#eeeeee;";
var back_css = [
"background-image:none;",
"background-color:white; ",
"opacity:0.90;"
].join('');
var comment_height = 250;
var option_height = 80;
// for comment area
var comment_area_css = [
"left:20px; ",
"right:0px; ",
"bottom:0px; ",
"text-align:left; ",
"position:fixed; ",
"z-index:100; ",
"height:" + comment_height + "px; ",
"margin:0px; ",
"padding:0px;",
back_css,
font_css
].join('');
// for comment
var comment_css = [
"position:relative; ",
"bottom:0px; ",
"border: 1px solid #999999; ",
"overflow:auto; ",
"margin:0px; ",
"height:" + comment_height + "px; ",
back_css,
font_css
].join('');
// for count
var count_css = [
"position:absolute; ",
"text-align:right; ",
"right:0px; ",
"position:absolute; ",
"border:1px solid #999999; ",
"top:-" + (option_height-2) + "px; ",
back_css,
font_css,
"opacity:0.2; "
].join('');
// for count(number)
var number_css = "font-weight:bold;";
// for options
var option_css = [
"left:0px; ",
"right:0px; ",
"position:absolute; ",
"border:1px solid #999999; ",
"marginargin:0px; ",
"border-bottom:0; ",
"line-height:110%; ",
"height:" + option_height + "px; ",
"top:-" + option_height + "px; ",
back_css,
font_css
].join('');
// for stress text of option
var option_text_css = "font-weight:bold; text-decoration:underline;";
// for anchor
var anchor_css = [
"font-size:100%;",
"color:blue;",
"text-decoration:none;",
back_css
].join('');
// for mini mode
var mini_css = [
"right:0px;",
"bottom:0px; ",
"text-align:right; ",
"position:fixed; ",
"overflow:auto; ",
"z-index:100; ",
back_css,
font_css,
// "padding-left:10px; ",
// "padding-right:10px; ",
"border-top: 1px solid #666666; ",
"border-left: 1px solid #666666; "
].join('');
// for mini mode list area
var mini_lt_css = [
"border-top: 0px; ",
"border-left: 0px; ",
"padding-left:0px; ",
"padding-right:0px; "
].join('');
// for mini mode open area
var mini_op_css = [
"background-color:red; ",
"opacity:0.90;",
button_font_css,
"border-top: 1px solid #666666; ",
"border-left: 1px solid #666666; "
].join('');
// for mini mode close area
var mini_cl_css = [
"background-color:blue; ",
"opacity:0.90;",
button_font_css,
"border-top: 1px solid #666666; ",
"border-left: 1px solid #666666; "
].join('');
// for mini mode mini area
var mini_mini_css = [
"right:0px;",
"bottom:0px; ",
"height:15px; ",
"width:7px; ",
"text-align:right; ",
"position:fixed; ",
"overflow:auto; ",
"z-index:99; ",
"background-color:red; ",
"opacity:0.90;",
button_font_css,
"border-top: 1px solid #666666; ",
"border-left: 1px solid #666666; "
].join('');
// tag cloud
var tag_cloud_min_size = 15;
var tag_cloud_max_size = 50;
try{
if (self.location.href!=top.location.href || !document.body) return;
}catch(e){
return;
}
var uri = top.location.href.replace(/#/g, '%23');
var w = contentWindow;
var option = new Option();
var comment_area = new CommentArea();
var is_load = false;
// --------------------------------------------------------------
// Comment Area
// --------------------------------------------------------------
function CommentArea (show) {
this.comments = [];
this.comments_no_dup = false;
var counts = [];
CommentArea.prototype.setup = function () {
if(this.id) return;
this.id = 'SBMCommentsViewerArea';
this.div = document.createElement('div');
this.div.setAttribute('id', this.id);
this.div.setAttribute('style', comment_area_css + 'display:none;');
this.div.addEventListener("dblclick", function(){comment_area.hide()}, false);
document.body.appendChild(this.div);
this.id_option = 'SBMoptionsViewerOptionArea';
this.option = document.createElement('div');
this.option.setAttribute('id', this.id_option);
this.option.setAttribute('style', option_css);
this.div.appendChild(this.option);
this.id_panel = 'SBMCommentsViewerCommentArea';
this.comment = document.createElement('ol');
this.panel = document.createElement('div');
this.panel.setAttribute('style', comment_css);
this.panel.setAttribute('id', this.id_panel);
this.div.appendChild(this.panel);
this.id_count = 'SBMCommentsViewerCountArea';
this.count = document.createElement('div');
this.count.setAttribute('id', this.id_count);
this.count.setAttribute('style', count_css);
this.count_opacity = this.count.style.opacity;
this.count.addEventListener("mouseover", function(){
this.style.opacity = '1.0';
}, false);
this.count.addEventListener("mouseout", function(){
this.style.opacity = comment_area.count_opacity;
}, false);
this.div.appendChild(this.count);
this.id_mini = 'SBMCommentsViewerMini';
this.mini = document.createElement('div');
this.mini.setAttribute('id', this.id_mini);
this.mini.setAttribute('style', mini_css + 'display:none');
document.body.appendChild(this.mini);
this.id_miniop = 'SBMCommentsViewerMiniOpen';
this.miniop = document.createElement('span');
this.miniop.setAttribute('id', this.id_miniop);
this.miniop.innerHTML = "&lt;";
this.miniop.setAttribute('style', mini_op_css );
this.miniop.addEventListener(mouse_event_show, function(){comment_area.show()}, false);
this.mini.appendChild(this.miniop);
this.id_miniop = 'SBMCommentsViewerMiniList';
this.minilt = document.createElement('span');
this.minilt.setAttribute('id', this.id_minilt);
this.minilt.setAttribute('style', mini_lt_css );
this.mini.appendChild(this.minilt);
this.id_minicl = 'SBMCommentsViewerMiniClose';
this.minicl = document.createElement('span');
this.minicl.setAttribute('id', this.id_minicl);
this.minicl.innerHTML = "&gt;";
this.minicl.setAttribute('style', mini_cl_css );
this.minicl.addEventListener(mouse_event_show, function(){comment_area.minishow()}, false);
this.mini.appendChild(this.minicl);
this.id_minimini = 'SBMCommentsViewerMinimini';
this.minimini = document.createElement('div')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment