「GM 脚本」大会员 B 币领取提醒 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
wdssmq
V2EX    分享创造

「GM 脚本」大会员 B 币领取提醒

  •  
  •   wdssmq
    wdssmq 2022-02-06 13:25:03 +08:00 3570 次点击
    这是一个创建于 1419 天前的主题,其中的信息可能已经有所发展或是发生改变。

    大部分脚本都以自用优先,所以可能塞了奇怪的功能进去,建议摘取需要的部分自行组织完整代码;

    name:「 bilibili 」- 稍后再看导出为.url

    desc:将 B 站的稍后再看列表导出为.url 文件

    url: https://github.com/wdssmq/userscript/blob/master/bilibili/later.user.js

    cdn: https://cdn.jsdelivr.net/gh/wdssmq/userscript@master/bilibili/later.user.js

    以及,现在才知道 localStorage 并不能跨子域使用,所以用了 cookie ,其实好像用GM_setValue+GM_getValue也可以;

    大会员 B 币领取提醒核心代码:

    // @grant GM_notification // @grant GM.openInTab // ==/UserScript== /* jshint esversion:6 */ (function () { "use strict"; // 基础函数或变量 const curUrl = window.location.href; const curDate = new Date(); const $ = window.$ || unsafeWindow.$; const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); const _log = (...args) => console.log('[bilibili-helper]', ...args); const _warn = (...args) => console.warn('[bilibili-helper]', ...args); const _error = (...args) => console.error('[bilibili-helper]', ...args); function $n(e) { return document.querySelector(e); } function $na(e) { return document.querySelectorAll(e); } // cookie 封装 const ckeObj = { setItem: function (key, value) { const Days = 137; const exp = new Date(); exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000); document.cookie = key + "=" + encodeURIComponent(value) + ";path=/;domain=.bilibili.com;expires=" + exp.toGMTString(); }, getItem: function (key, def = "") { const reg = new RegExp("(^| )" + key + "=([^;]*)(;|$)"); const arr = document.cookie.match(reg); if (arr) { return arr[2]; } return def; } }; // B 币领取提醒 (() => { const ckeName = "bilibili-helper-bcoin-lstMonth"; const curMOnth= curDate.getMonth() + 1; const lstMOnth= ckeObj.getItem(ckeName, 0); const bcoinUrl = "https://account.bilibili.com/account/big/myPackage"; // 元素变化监听 const fnElChange = (el, fn = () => { }) => { const observer = new MutationObserver((mutationRecord, mutationObserver) => { _log('body attributes changed!!!'); // body attributes changed!!! _log('mutatiOnRecord= ', mutationRecord); // [MutationRecord] _log('mutatiOnObserver=== observer', mutatiOnObserver=== observer); // true fn(mutationRecord, mutationObserver); mutationObserver.disconnect(); }); observer.observe(el, { // attributes: false, // attributeFilter: ["class"], childList: true, // characterData: false, subtree: true, }); } // 通知事件封装 const fnNotify = (title, body) => { GM_notification({ title: title, text: body, timeout: 0, onclick: () => { // window.location.href = bcoinUrl; GM.openInTab(bcoinUrl, false); } }); } // 判断是否已经领取过 const fnCheckByDOM = () => { const $bcoin = $n(".bcoin-wrapper"); _log("---"); // $bcoin && _log($bcoin.innerHTML); if ($bcoin && $bcoin.innerText.includes("本月已领")) { ckeObj.setItem(ckeName, curMonth); return true; } else { fnElChange($n("#app"), fnCheckByDOM); } return false; } // _log($n("body").innerHTML); // _log(lstMonth, curMonth); // 对比 cookie 数据 if (lstMonth != curMonth) { _log(curUrl, bcoinUrl); if (curUrl.indexOf(bcoinUrl) > -1) { fnCheckByDOM(); } else { fnNotify("B 币领取提醒", "点击查看 B 币领取情况"); } } })(); })(); 
    6 条回复    2022-05-01 19:09:24 +08:00
    qaweqa
        1
    qaweqa  
       2022-02-06 15:00:57 +08:00
    发布在 GreasyFork 之类的网站可能比较好?
    lower
        2
    lower  
       2022-02-06 15:55:56 +08:00
    有没有屏蔽 b 站指定视频的脚本?

    按理说把某个 up 屏蔽了,他的作品也应该自动不推荐出来,可是垃圾 B 站还是乱七八糟一直在首页显示

    好歹搞个 ytb 的不喜欢功能啊……
    CallMeReznov
        3
    CallMeReznov  
       2022-02-06 19:40:09 +08:00
    @lower #2 在外面点不推荐该 UP 的选项还是会推荐?
    VZEXEZVzzz
        4
    VZEXEZVzzz  
       2022-02-06 22:36:20 +08:00
    感谢楼主让我知道大会员能领 B 币=0=
    wlb955
        5
    wlb955  
       2022-02-10 10:17:06 +08:00
    能不能脚本直接给领了,然后给个领取成功 or 失败的反馈
    wdssmq
        6
    wdssmq  
    OP
       2022-05-01 19:09:24 +08:00
    userscript/bilibili at master wdssmq/userscript

    https://github.com/wdssmq/userscript/tree/master/bilibili

    源码地址。。
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1307 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 29ms UTC 17:07 PVG 01:07 LAX 09:07 JFK 12:07
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86