|
1 | 1 | // ==UserScript== |
2 | 2 | // @name 知乎增强 |
3 | | -// @version 1.6.7 |
| 3 | +// @version 1.6.8 |
4 | 4 | // @author X.I.U |
5 | 5 | // @description 移除登录弹窗、默认收起回答、一键收起回答、收起当前回答/评论(点击两侧空白处)、快捷回到顶部(右键两侧空白处)、屏蔽用户 (发布的内容)、屏蔽关键词(标题/评论)、屏蔽指定类别(视频/文章等)、屏蔽盐选内容、展开问题描述、置顶显示时间、完整问题时间、区分问题文章、直达问题按钮、默认高清原图、默认站外直链 |
6 | 6 | // @match *://www.zhihu.com/* |
@@ -116,21 +116,21 @@ function menu_setting(type, title, tips, line, menu) { |
116 | 116 | if (line) _br = '<br>' |
117 | 117 | for (let i=0; i<menu.length; i++) { |
118 | 118 | if (GM_getValue(menu[i][0])) { |
119 | | - _html += `<input name="zhihuE_Setting" id="${menu[i][0]}" type="checkbox" value="${menu[i][0]}" checked="checked"><label for="${menu[i][0]}">${menu[i][1]}</label>${_br}` |
| 119 | + _html += `<label><input name="zhihuE_Setting" type="checkbox" value="${menu[i][0]}" checked="checked">${menu[i][1]}</label>${_br}` |
120 | 120 | } else { |
121 | | - _html += `<input name="zhihuE_Setting" id="${menu[i][0]}" type="checkbox" value="${menu[i][0]}"><label for="${menu[i][0]}">${menu[i][1]}</label>${_br}` |
| 121 | + _html += `<label><input name="zhihuE_Setting" type="checkbox" value="${menu[i][0]}">${menu[i][1]}</label>${_br}` |
122 | 122 | } |
123 | 123 | } |
124 | 124 | _html += `</div></div></div>` |
125 | 125 | document.body.insertAdjacentHTML('beforeend', _html); // 插入网页末尾 |
126 | | - setTimeout(function() { // 延迟 100 毫秒 |
| 126 | + setTimeout(function() { // 延迟 100 毫秒,避免太快 |
127 | 127 | // 关闭按钮 点击事件 |
128 | 128 | document.querySelector('.zhihuE_SettingClose').onclick = function(){this.parentElement.parentElement.parentElement.remove();document.querySelector('.zhihuE_SettingStyle').remove();} |
| 129 | + // 点击周围空白处 = 点击关闭按钮 |
| 130 | + document.querySelector('.zhihuE_SettingBackdrop_2').onclick = function(event){if (event.target == this) {document.querySelector('.zhihuE_SettingClose').click();};} |
129 | 131 | // 复选框 点击事件 |
130 | 132 | document.getElementsByName('zhihuE_Setting').forEach(function (checkBox) { |
131 | | - checkBox.addEventListener('click', function(){ |
132 | | - if (this.checked) {GM_setValue(this.id, true);} else {GM_setValue(this.id, false);} |
133 | | - }); |
| 133 | + checkBox.addEventListener('click', function(){if (this.checked) {GM_setValue(this.value, true);} else {GM_setValue(this.value, false);}}); |
134 | 134 | }) |
135 | 135 | }, 100) |
136 | 136 | } |
|
0 commit comments