显示标签为“Tampermonkey”的博文。显示所有博文
显示标签为“Tampermonkey”的博文。显示所有博文

Xunlei Download Link for ffdy

Xunlei Download link for ffdy.cc

今天搜索电影搜到放放电影这么一个网站,有链接却不能用迅雷下载,幸好还能云点播,然后观察了一下URL和下载地址就随手写了一个小脚本把地址提出来方便一点.顺便回忆一下暑假看得一点点Javascript.

脚本地址:http://userscripts.org/scripts/show/182672

Tampermonkey调用外部编辑器编辑userscript

在Chrome下有一Tampermonkey的插件,管理油猴子脚本,本身也自带一个编辑器,但是用它的编辑器功能上总有缺陷,而Tampermonkey(以下简称“TM")又不能直接调用磁盘的上的脚本,所以通过特殊方式实现用外部编辑器编辑磁盘上的js文件,然后Tampermoney自动加载自动调用。
以下来自TM的论坛

@require tag能够调用到本地磁盘上的文件,使用这种@require方法可能会有延迟。
具体方法:

  • 打开Chrome扩展管理,勾选TM“允许访问文件网址”
  • 进入TM管理,添加一个新脚本
  • 打开文件管理器,找到脚本存放位置
  • 用中意的编辑器打开脚本
  • 复制脚本Header,在新脚本提交
  • 复制脚本在本机存放的位置
  • 在TM中新建的脚本Header位置插入新行 ---- ”//@require file://<path>/<filename>"
  • 保存TM中新脚本,然后就结束了。

我将英文贴在下面:
  • first go to Chrome's extensions page and check if the "Allow access to file URLs" setting is enabled for TM
  • now goto TM's context menu and click at "Add a new script..." a new TM options tab opens
  • open the file browser (Explorer, Nautilus, ...) and go to the location where the script is placed
  • open your script with your prefered (external) editor
  • copy the userscript header (only the header is needed!) to TM's options tab
  • go to the file browser and click at the address bar (Explorer) or press CTRL-L (Nautilus)
  • copy the path and go back to TM's options tab
  • insert a new line with a valid path and filename to the userscript header: "@require file://<path>/<filename>"
  • save the newly added script and you're done!
一个例子:假设你的脚本在C:\Users\janb\Documents\Scripts\test.js 并且开头如下:
// ==UserScript==
// @name Test'Em'All
// @namespace http://tampermonkey.net/empty.html
// @version 0.1
// @description this does nothing but giving a good example
// @match http://tampermonkey.net/empty.html
// ==/UserScript==

console.log("running at " + window.location.href);
// Normal script now do a lot of other things...

接下来你在TM中创建一个新脚本,内容如下:
// ==UserScript==
// @name Test'Em'All
// @namespace http://tampermonkey.net/empty.html
// @version 0.1
// @description this does nothing but giving a good example
// @match http://tampermonkey.net/empty.html
// @require file://C:\Users\janb\Documents\Scripts\test.js
// ==/UserScript==
结束
现在你就可以编辑本地”C:\Users\janb\Documents\Scripts\test.js“的文件,所有修改都会及时的反映到“http://tampermonkey.net/empty.html”这个网址。

几个注意点:

  • 一定注意将TM的允许访问本地文件勾选上~
  • 如果你的本地地址中文件夹有空格,用 %20 代替 ,例如“file://C:\Eigene%20Dateien\test.js”
  • 你的本地文件不要以 user.js 结尾,user.js文件会被Chrome接管,TM不能接受到~

给Linux用户的注意点:
不要用“~”来表示home directory
在路径开始的时候加“/“ 例如:”file:///home/janb/Documents/test.js“

最后再一次感谢TM的开发人员。
TM的一片通用教程

Tampermonkey--Chrome下神一样的插件

根据Tampermonkey在Google Code页面的介绍,Tampermonkey是一款在Google Chrome和Chromuim浏览器中提供“油猴子脚本”支持的工具。Tampermonkey是Google Chrome中最流行的一款脚本管理插件。它的API完全兼容“油猴子脚本”,它还加入更多的 Chrome 本身不支持的用户脚本功能,比如 GM_registerMenuCommand 和 GM_xmlhttpRequest这两个函数。
安装地址:Chrome Web Store
Tampermonkey is a tool that provides Greasemonkey script support for Google Chrome and Chromium Browser. It's API is fully compatible to Greasemonkey, including GM_registerMenuCommand, GM_xmlhttpRequest with cross domain support and access to the unsafeWindow object.

什么是浏览器用户脚本(Userscript)?

当用户浏览网页时,会从服务器上下载脚本,并在本地运行,这种脚本我们会称之为网页脚本。与网页脚本不同的,用户脚本本身就在客户机上,不需要下载,而且如果不对其做限制,可用在所有网页上。浏览器用户脚本通常使用Javascript语言编写。

通过编写用户脚本,可以很大程度上提高上网体验。譬如使用 Userscript可以实现网页自动翻页、文字翻译、页面预读、看图增强等等有用、有趣的功能。

Userscript虽然很自由很强大,但出于安全性原因,使用的时候会有些限制,如 Userscript不能操作文件、不能操作剪贴板等。
参考

Tampermonkey功能

  1. 管理和编辑所有的用户脚本
  2. 点击启动和禁用脚本
  3. 在不同Chrome中同步所有的脚本
  4. 通过URL搜索用户脚本(确保启用TamperFire)

Features:
 - manage and edit all your userscripts
 - enable and disable your scripts with 2 clicks
 - easily sync you scripts between different Chrome instances
 - search scripts from userscripts.org by URL (with TamperFire enabled)

使用Tampermonkey同步脚本


  1. 将"Config mode"切换到"Advanced"
  2. 找到"TESLA BETA"启动"Enable TESLA","type"选用“Chrome sync(Beta)”,save
  3. 这样所有的脚本都不会丢失了,不会发生我重装系统丢失所有脚本的情况了。

Tampermonkey何时同步:
1) before every TM update check
2) whan a script is changed locally
3) when TM starts
4) every 5h (will become configurable)
参考

安装脚本过程

找到你想要安装的用户脚本,例子中使用“Download YouTube Videos as MP4”脚本,更多推荐脚本可以看我这篇文章,一下在Chrome中执行。
到了这个界面可以点击右上角的“Install”,然后会自动调用Tampermonkey
点击“OK”
这个界面可以看到脚本要求的权限和版本信息等等信息。点击“OK”整个安装过程就结束了。
最后晒晒我的脚本

如果想要深入了解一下油猴子用户脚本,可以参考一下这本书《深入浅出Greasemonkey
参考以下文章
http://www.iplaysoft.com/greasemonkey.html
http://pcedu.pconline.com.cn/soft/wl/brower/1206/2839052.html
http://www.cnblogs.com/kuber/archive/2010/04/08/Why_Userscripts_Is_Not_Better_Than_Extensions.html

Quote Of The Day