[Tampermonkey] 受隔壁帖子启发, 整了一个油猴脚本

2022-09-07 17:06:18 +08:00
 Al0rid4l

用来每天上网提醒自己好好赚钱, 早日远离这些生物

// ==UserScript==
// @name        Ruler
// @namespace   Violentmonkey Scripts
// @include *
// @grant       none
// @version     1.0
// @license     MIT
// @author      fuckduanluan
// @description Inspired by https://www.v2ex.com/t/878358
// ==/UserScript==


window.addEventListener('load', () => {
  const dec = decodeURIComponent,
      enc = encodeURIComponent,
      decode = function decode(s) {
    return s.replace(/(%[0-9A-Z]{2})+/g, dec);
  };

  function setCookie(key, value, _temp) {
    let _ref = _temp === void 0 ? {} : _temp,
        expires = _ref.expires,
        domain = _ref.domain,
        secure = _ref.secure,
        _ref$path = _ref.path,
        path = _ref$path === void 0 ? '/' : _ref$path;

    if (typeof value !== 'string') {

      value = String(value);
    }


    key = enc(key.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, dec));


    value = enc(value.replace(/%(23|24|26|2B|5E|60|7C)/g, dec).replace(/[\\]/g, escape));
    let text = key + "=" + value;
    text += "; path=" + path.split(';')[0];

    typeof expires === 'number' && (expires = new Date(Date.now() + expires * 36e5)); 


    expires instanceof Date && (text += "; expires=" + expires.toUTCString());
    typeof domain === 'string' && (text += "; domain=" + domain.split(';')[0]);
    secure && (text += '; secure');
    return document.cookie = text;
  }

  function getCookie(key) {
    const cookies = document.cookie ? document.cookie.split('; ') : [],
        rst = [];

    for (let i = 0, len = cookies.length; i < len; ++i) {
      let part = cookies[i].split('='),
          name = decode(part[0]),
          value = decode(part.slice(1).join('='));
      name === key && rst.push(value);
    }

    return rst.length ? rst.length === 1 ? rst[0] : rst : null;
  }
  if (getCookie('hasBanner')) return;
  
  const banner = document.createElement('div');
  banner.style.cssText = `
    color: #eee;
    font-size: 24px;
    text-shadow: 0 3px 3px #666;
    line-height: 22px;
    padding: 8px;
    font-family: "Microsoft Yahei";
    text-align: center;
    cursor: pointer;
    position: fixed;
    top: 0px;
    left: 0px;
    right: 0px;
    z-index: 9999;
    background: linear-gradient(-45deg, #0057b7 25%, #ffd700 0, #ffd700 50%, #0057b7 0, #0057b7 75%, #ffd700 0);
    background-size: 100px 100px;
    box-shadow: 0 3px 10px #aaa;
  `;
  banner.textContent = '我们终将在没有黑暗的地方相见';
  banner.addEventListener('click', function() {
    this.style.display = 'none';
    setCookie('hasBanner', 1, { expires: 24 * 7 });
  });
  document.body.appendChild(banner);
});

内容可以改成自己喜欢的, 默认点击即可隐藏一周 Enjoy

2247 次点击
所在节点    分享创造
9 条回复
Al0rid4l
2022-09-07 17:07:12 +08:00
DAPTX4869
2022-09-07 17:27:25 +08:00
你不关心政治 政治就来关心你
chonger
2022-09-07 17:40:41 +08:00
哈哈~~赞一个~
nah
2022-09-07 19:40:40 +08:00
author id 不错~
Jirajine
2022-09-07 21:46:37 +08:00
“没有黑暗的地方” 是指灯火通明的审讯室吗?😅
Al0rid4l
2022-09-07 22:28:20 +08:00
@Jirajine 在故事里当然, 我也感受过结局带来的窒息感, 不过不影响借用这句话, 毕竟谁都希望这句话真的能够实现
minamike
2022-09-08 11:23:29 +08:00
@DAPTX4869 你关心了政治 政治就没有关心你了吗
DAPTX4869
2022-09-08 11:28:15 +08:00
@minamike #7 非常关心 天天都问做核酸了没
minamike
2022-09-08 11:52:24 +08:00
@DAPTX4869 所以关不关心没区别 不如润

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/878396

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX