SparkPlug

一月 26, 2008

MPD听网络电台

归类于: howto, misc — sparkplugcn @ 5:40 am

ShoutCast是我常 听的电台 ,用MPD的话需要稍微的改动一下.

  1. 安装MPC
    emerge -av mpc
  2. 寻找两个执行文件
    gentoo是放在/usr/share/doc/mpc-*里,名字分别为pls-handler.shm3u-handler.sh,如果没有找到这两个文件也可以自己写
    pls-handler.sh

    #!/usr/bin/env sh
    mpc clear
    grep ‘^File[0-9]*’ $1 | sed -e ’s/^File[0-9]*=//’ | mpc add
    mpc play

    m3u-handler.sh script

    #!/usr/bin/env sh
    mpc clear
    cat $1 | mpc add
    mpc play

  3. 把这两个文件cp到自己的家目录里,然后修改为可执行文件

    chmod u+x m3u-handler.sh
    chmod u+x pls-handler.sh

  4. 修改Fireofx支持
    找开Firefox,在菜单里依次打开”edit-preferences-downloads”,在”file types”里如果已经存在pls和m3u的选项,删除它们.
    然后去ShoutCast或者想去的电台主页,点击想听的电台地址,FX会弹出对话框,选择”open with” 和 “other”,然后连接到上面两个可执行文件,就可以了.

这样就不用再听国内的大力丸的广告了:)Good Luck.

Powered by ScribeFire.

一月 24, 2008

自动翻页autopager

归类于: firefox — sparkplugcn @ 1:34 pm

像Google,凯迪这样的网站每页的内容太少,Autopage的功能很重要.Google可以用的GreaseMonkey的JS不少,不过对于凯迪这样的需要Javascript的俺不会改,好在有Autopapger这样的扩展.
但是这个扩展有一个问题就是会拖慢FX,不知道什么原因,好在俺在FX的Autopage相应目录里删除了所有的xml文件,只然后保留了想要的,这样的话速度就还说的过去的.
凯迪的设置已经提交给了作者,不知道能不能加的上.下图五个蓝框里是设置的主要参数,其它的看自己喜好

如果这个用不惯,也可以试一下repagination这个扩展.

Powered by ScribeFire.

一月 21, 2008

第一个greasemonkey的脚本

归类于: firefox — sparkplugcn @ 1:43 am

凯迪的广告太多了,于是硬着头皮做了第一个脚本.放在这里
// This is my first greasymonkey script:)
// ——————————————————————–
// Modify by MOH at 2008.01.21
// ==UserScript==
// @name MyCat
// @namespace http://sparkplug-moh.blogspot.com
// @description Block some ad cheater.I know nothing about javascript,this script is based on dvbbskilluser.user.js and someothers,thanks evryone.
// @include http://*.cat898.com/newbbs/list*
// ==/UserScript==

var allLinks, thisLink,theWho,theTr;
//在下面写上想要屏蔽的ID的名字,注意格式,并保存为utf8
var cheater= new Array(“张三” , “李四” , “王二麻子”, “Mike” , “Jack”);
allLinks = document.evaluate(
“//td[count(a)=1]“,
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < allLinks.snapshotLength; i++) {
thisLink = allLinks.snapshotItem(i);
theWho = thisLink.firstChild;
for (var j = 0; j < cheater.length;j++) {
if (theWho.innerHTML == cheater[j]){
theTr=theWho.parentNode.parentNode;
theWho.parentNode.parentNode.parentNode.removeChild(theTr);
}
}
}
/*block the web element what I dont want to see,but I think that the firefox another extention Adblock Plus can do this better by add the two rules like below:
屏蔽掉一些不想看到的东西,其实用Adblock Plus这个扩展更好,方法是加入下面这两条规则
cat898.com#TR(id^=follow)
cat898.com#div(id$=coco)
*/
var cleanPath = “//div[@id] | //tr[@id]“;
var allClean, thisClean;
allClean = document.evaluate(
cleanPath,
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var x = 0; x
theClean = allClean.snapshotItem(x);
theClean.parentNode.removeChild(theClean);
}
/*center the web.Before do this ,must bloock something like above.
修改一下页面显示,前提是做了上面的修改.
*/
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName(‘head’)[0];
if (!head) { return; }
style = document.createElement(’style’);
style.type = ‘text/css’;
style.innerHTML = css;
head.appendChild(style);
}

addGlobalStyle(‘.tableborder1 { width: 1000px ; }’);
//
//

效果图

Powered by ScribeFire.

Blog at WordPress.com.