Skip navigation.

Fat R笔记……与减肥无关

Fat awful terrible Rubbish-bin

一个简单的UserJS

, ,

用于“过滤”http://divx.thu.cn/latest.php 输出。其实只是用不同颜色标示不同类型的rlz,目前区分的是internal、screener、tc/ts/cam等类别。代码如下:
// ==UserScript==
// @name             divx.thu.cn filter
// @version          1.00
// @author           Returner
// @namespace        http://my.opera.com/Returner
// @include          http://divx.thu.cn/latest.php*
// ==/UserScript==

/*Changelog:
 *  1.00: First version.
 */

function divxcolor() {
  var titleColors = {    //这些颜色是随便写的,巨丑
    internal: '#A08585',
    historic: '#A0A585',
    screener: '#B0A585',
    ts: '#707070',
    dummy: '#000000'
  };

  var blockColors = {    //三种类型:none表示不显示标题下面的block,ori表示不改变颜色,#xxxxxx表示用指定颜色显示
    //internal: '#ffeeee',
    internal: 'none',
    historic: 'none',
    //screener: 'ori',
    screener: 'none',
    ts: 'none',
    dummy: '#000000'
  };
  var dTables = document.getElementsByTagName("table");
  for (var i = 0, thisTab; thisTab = dTables[i]; i++){
    if (thisTab.getAttribute('id') == 'table14'){
      var URLText = thisTab.rows[0].cells[0].getElementsByTagName("a")[0].innerText;
      var tabType = 'normal';
      if(URLText)
        if (URLText.match(/\.iNT(ERNAL)?[\.\-]/)){
          tabType = 'internal';
        } else if (URLText.match(/\.19[0-8][\d][\.\-]/)){  //电影时间年份较早的rlz
          tabType = 'historic';
        } else if (URLText.match(/\.(DVDSCR)|(screener)[\.\-]/i)){
          tabType = 'screener';
        } else if (URLText.match(/\.((TS)|(TC)|(CAM)|(TELESYNC))+[\.\-]/i) ){
          tabType = 'ts';
        }

      if (tabType == 'normal'){
        thisTab.rows[0].cells[0].setAttribute('background','/images/001.jpg');
      } else{
        thisTab.rows[0].cells[0].setAttribute('background','');
        thisTab.rows[0].cells[0].setAttribute('bgColor',titleColors[tabType]);
        thisTab = dTables[++i];
        if(blockColors[tabType] == 'none'){
          thisTab.innerHTML = '';
        } else if(blockColors[tabType] == 'ori'){

        } else{
          thisTab.rows[0].cells[0].setAttribute('bgColor',blockColors[tabType]);
        }
        /*thisTab = dTables[++i];
        thisTab.setAttribute('bgColor',tagColors.intBlock1);
        thisTab.rows[1].cells[0].setAttribute('bgColor',tagColors.intBlock1);*/
      }
    }
  }
}
window.opera.addEventListener('AfterEvent.DOMContentLoaded',
  function (ev) {
    divxcolor();
  },
false);


Notes:
  * 在判断ts时,如果正则表达式用/.(TC)|(TS)|(CAM)|(TELESYNC)[.\-]/i,会把标题含有.tsxxxx.之类文本的也判断为真,改成/.((TS)|(TC)|(CAM)|(TELESYNC))+[.\-]/i就OK了。所以前面判断screener的严格来说不太完善

  * Opera下不支持thisTab.rows[0].cells[0].background,所以用DOM的方法thisTab.rows[0].cells[0].setAttribute('background','/images/001.jpg')

  * 获得单元格中的<A>标签可以用thisTab.rows[0].cells[0].all.tags["a"],Opera也支持,但这里还是用了W3C DOM的标准thisTab.rows[0].cells[0].getElementsByTagName("a")

  * 访问一个Object的属性,可以用object.property,也可以用object["property"]。这个程序访问titleColors和blockColors时用的是后者

  * 有空一定要多学学DOM的东西,目前为止我还是这方面的白痴……

dpkg安装base-passwd时遇到一个奇怪的问题昨天开始,我的手机将长期处于漫游状态……

Comments

Anonymous 21. August 2006, 06:49

Henry writes:

strong.....

Returner 21. August 2006, 06:53

-__________-

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies