Fermat618's Blog

Happy coding

又写了个油猴脚本

Fermat618 posted @ 2014年10月11日 15:50 in 未分类 , 4554 阅读

来个总结吧。

首先,是如何看到脚本出错信息。脚本出错的信息,只有在全浏览器的控制台下面,才可以看到。按 Ctrl + Shirt + J, 可以进入浏览器的控制台。在过滤窗口,输入脚本的名字的一部分,可以过滤出错信息。网页上的 javascript, 普通写得烂,出错信息一堆堆的,不过滤 ,有用的信息就会被淹没。

临时调试脚本,可以使用 Firefox 自带的代码片段速记器(shift + F4)。按 Ctrl + / 可以方便地注释掉一行。想知道某些东西有哪些方法可以调用,可以选中那个对象(或返回一个对象的表达式),按查看,就可以看到。

Firefox 自带的开发者工具的好用程度,已经超出了 firebug, 所以不推荐用firebug 了。

如何存储信息。使用 GM_getValue, GM_setValue, GM_deleteValue, GM_listValues 等函数,可以针对每个脚本存储本地信息。由于单个的 GM_setValue 不可以存储列表,我把整个存储空间当成一个列表来使用了,反正我与个脚本也只需要存储一个列表。要再加功能,另开一个脚本就好了。

写稍复杂点的功能时,使用 typescript 比直接使用 javascript 爽多了。特别是想建立类的时候,代码干净了很多。

最后,说一下我写的这个脚本的功能。上论坛时,总会遇到某些令人不愉快的人,而很多地方又没有提供黑名单功能。为了屏蔽掉这些人的帖子,我以前写了一个脚本,把这些人的名字保存起来,然后过滤掉这些人发的帖子。但是那些个名字都是以字面形式保存在代码里面的,每次需要把人加入时,就要手动打开程序,编辑文本,很是麻烦。所以,这回我把代码改了一下,直接点击鼠标就可以把某些人加入到黑名单里面。

mega888 official doa 说:
2021年8月30日 00:10

This is exciting, nevertheless it is vital for you to visit this specific url:

Satta king 说:
2021年9月25日 05:18

On that website page, you'll see your description, why not read through this.

AP SSC Assignment Qu 说:
2022年9月09日 22:08

Department of Government Examinations and Secondary Education Board Andhra Pradesh has conducted the Assignment Exams multiple times in the academic year in Session-1 and Session-2 (Term-1 & Term-2). There are four exams are conducted Assignment-1, Assignment-2, Assignment-3 and Assignment-4. AP SSC Assignment Question Paper Every Class 10th Standard Student Studying in Government & Private Schools in Telugu Medium, English Medium & Urdu Medium can download the AP 10th Assignment Model Paper 2023 with answer solutions for theory, objective and bit questions. Subject experts of the board have designed and introduced the practice question bank for all Part-A, Part-B, Part-C, and Part-D exams.

civaget 说:
2024年1月18日 01:23

펀초이스 takes the guesswork out of massage selection, making it easy to find the perfect escape from stress.

civaget 说:
2024年1月18日 05:58

제주레깅스룸 celebrates leggings in style. It's a fantastic place to discover new fashion trends and unleash your inner fashionista.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter