Greasy Fork

来自缓存

Greasy Fork is available in English.

向猫抓发送一条资源的示例

示例 向猫抓发送一条资源

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         向猫抓发送一条资源的示例
// @namespace    https://bmmmd.com/
// @version      0.1
// @description  示例 向猫抓发送一条资源
// @author       bmm
// @match        https://o2bmm.gitbook.io/cat-catch/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bmmmd.com
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    /*
        参数说明
        action 发送资源固定为 catCatchAddMedia
        url 资源地址
        href 当前页面地址 一般为 location.href 即可
        ext 资源的扩展 不带“.” 如 mp4
        mime 资源的mime
        referer 打开资源所需的 referer
    */
    // 发送一条资源地址
    window.postMessage({
        action: "catCatchAddMedia",
        url: "https://github.com/xifangczy/cat-catch",
        href: location.href,
        ext: "html",
        mime: "test/text",
        referer: "https://github.com"
    });

    // 下载资源并转换成blob链接发送
    fetch("https://bmmmd.com/")
    .then(response => response.blob())
    .then(function (blob) {
        window.postMessage({
            action: "catCatchAddMedia",
            url: window.URL.createObjectURL(blob),
            href: location.href,
            ext: "html",
        });
    });

    /*
        参数说明
        action 发送密钥固定为 catCatchAddKey
        key 密钥
        href 当前页面地址 一般为 location.href 即可
        ext 密钥类型 
    */
    // 发送经过base64编码后的key
    window.postMessage({
        action: "catCatchAddKey",
        key: "5oGt5Zac5L2g77yM5Y+R546w5LiA5Liq5q+r5peg5oSP5LmJ55qE5b2p6JuL8J+QsQ==",
        href: location.href,
        ext: "base64Key",
    });
})();