hite / AccessHappily

受够了那些仅仅为了浏览网页都提示让你登录账户、登录 app、扫描微信关注的网址,这个工具为了关闭这些干扰元素
4 stars 0 forks source link

[指南][官方] 如何公开分享自己的规则集 #1

Open hite opened 8 months ago

hite commented 8 months ago

一、分享自己规则集的步骤

1.在AccessHappily 插件的规则编辑器里复制规则到粘贴板(或点击链接复制规则并分享自己的规则),打开在线规则列表 2.点击右上角 New issue 3.在第一条评论下添加一个纯粹是 JSON 对象的评论, 如下面的评论,注意:使用

```json {} ```

这样的markdown 标记*.

  1. 保存之后, 复制当前 issue 的 URL

二、订阅规则的步骤

1.回到 AccessHappily 插件的设置界面 2.切换填入此 URL, 添加适当的描述内容 3.点击添加

三、JSON 对象的格式

{ "name": string, required, 为规则起个名字, "author": string, required, 规则的创建者, "type": string, required, 规则的类型,如 cookie warning removal, 关闭登录弹窗, "matches": array, required, 规则的适用页面,如 ["知乎", "medium.com"], 只为了展示,不参与页面是否匹配规则的逻辑, "data": Object<Key, array>, required, 实际的规则.可以从自动生成的规则文件里 copy,或者根据规则手动书写, "remark": string, optional, 一些备注, }

四、Key 的格式

AccessHappily 获取到 URL = location.host + location.pathname , 使用此 URL,进行匹配(不包含 query 的参数)

https://keystonejs.com/docs/getting-started?type=CMS#where-to-next 实际计算时是 keystonejs.com/docs/getting-started

  • example.com/path*
  • 匹配 example.com/path/9H894.html
  • 不匹配 sub.example.com/path/9H894.html
  • *.example.com/path/*
  • 匹配 sub.example.com/path/9H894.html?t=123234234
  • *.example.com/path/9H894.html
  • 匹配 sub.example.com/path/9H894.html?t=123234234
  • file.exmaple.com
  • 匹配 file.example.com/path/9H894.html?t=123234234
  • 匹配 file.example.com/user/9H894.html?t=123234234
  • 不匹配 sub2.file.example.com/user/9H894.html?t=123234234

五、Rule 的格式

{ "name": string, required, 为规则动作起个名字, 规则被执行时,左上角提示的名称为了辨识当前执行的规则, "type": string 枚举, required, 规则的动作类型,如 autoHide | autoClick | autoNavigate | insertCSS | others, "data": string, required, 实际的规则.通常是普通的 CSS 选择器,如果 type = insertCSS 时, data 为完整的 style ,如 #content_views pre code{ user-select: text !important;}, " exampleUrl": string,optional, 使用工具生成规则时的页面地址,用来验证是否生效 }

六、规则样例见下一条评论

hite commented 8 months ago
{
    "name": "默认规则",
    "author": "官方",
    "type": "关闭登录弹窗#自动隐藏",
    "matches":["blog.csdn.net","知乎","medium.com"],
    "data": {
        "*.zhihu.com": [
          {
            "type": "autoClick",
            "name": "Close login dialogue",
            "data": ".Modal-closeButton"
          }
        ],
        "blog.csdn.net": [
          {
            "type": "autoHide",
            "name": "Close passport-login",
            "data": ".passport-login-container"
          },
          {
            "type": "insertCSS",
            "name": "Remove restriction for copy",
            "data": ".passport-container-mini {display: none !important;} #content_views pre code{user-select: text !important;} #content_views pre{ user-select: text !important;}"
          },
          {
            "type": "insertCSS",
            "name": "去掉关注才能阅读全文的限制",
            "data": "#content_views{height:auto !important; overflow: auto !important;}"
          }
        ],
        "www.jianshu.com/go-wild*": [
          {
            "type": "autoClick",
            "name": "ignore the warning for target page",
            "data": ":contains('继续前往')"
          }
        ],
        "link.zhihu.com/": [
          {
            "type": "autoClick",
            "name": "Auto open the external page",
            "data": ".content .link"
          }
        ]
      }
}