为你的网站添加'串门'功能
概述
本功能通过获取友联页面信息,配合随机函数
制作的类似于@开往的一个项目
添加代码
不知道如何添加代码的同学,可以看这篇文章
本代码由@张洪大佬页脚 JS 改造而来
1 | //默认以主题 Butterfly 为例 |
参数说明
选项 | 说明 |
---|---|
fetch | 填写你的友联页面,如"/link" |
n | 填写你友联页面中,网站名称哪一项的class |
a | 随机数开始生成的区间,默认为 0,可自行调节 |
l | 填写你友联页面中,地址的一项 |
setTimeout | 延迟,默认 2s |
开启弹窗
找到主题的配置文件
(大约在 840 行左右)
1 | # Snackbar (Toast Notification 彈窗) |
修改主题文件
需要修改的文件在\themes\butterfly\layout\includes\header\nav.pug
,其他主题可自行查找菜单
的 PUG 文件所在
1 | nav#nav |
修改 css
在你的自定义 CSS 文件中,加入以下信息
1 | #nav #random_flink { |
其中font-size
有你决定,可以在控制台
中进行测试
第三方主题
如果您的主题不包含SnackBar
模块,可找寻其他弹窗
替代,本文使用SnackBar
示例

通过外部链接引入文件
1 | inject: |
相关配置
Key | Default | Description |
---|---|---|
text | null | The text to displae inside the notification. |
textColor | #FFFFFF | Text color of the notification text. Default is white. |
pos | bottom-left | The position the notification will show. Refer to the examples above for possible positions. |
customClass | null | Add a custom class to the notification for custom styling. |
width | auto | Width of the notification. Used to shrink/expand window as you wish. |
showAction | true | Boolean to show the action buton or not. |
actionText | Dismiss | Text to display as the action button. |
actionTextAria | Dismiss, Description for Screen Readers | Text for screen readers. |
alertScreenReader | false | Determines if screen readers will annouce the snackbar message. |
actionTextColor | #4CAF50 | Text color of the action button. |
backgroundColor | #323232 | Background color of the notification window. |
duration | 5000 | Time in milliseconds the notification is displayed before fading out. |
onActionClick | function(ele) | Default action closes the notification. |
onClose | function(ele) | Fires when the notification has been closed. |
示例
1 | $(".button").click(function () { |
代码替换
1 | /**友联跳转 */ |
推荐阅读
后记
代码因为是由另一个功能改的,可能不太完善,如果有更好的方案建议在评论区留言
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 落星屋!
评论