()
| 279 | |
| 280 | // 替换为 sov2ex 搜索,代码来自 v2ex-plus 扩展:https://github.com/sciooga/v2ex-plus (懒得重复造轮子了~ |
| 281 | function soV2ex() { |
| 282 | document.body.appendChild(document.createElement('script')).textContent = ` |
| 283 | var $search = $('#search') |
| 284 | var searchEvents = $._data($search[0], "events" ) |
| 285 | var oKeydownEvent = searchEvents['keydown'][0]['handler'] |
| 286 | var oInputEvent = searchEvents['input'][0]['handler'] |
| 287 | $search.attr("placeholder","sov2ex") |
| 288 | $search.unbind('keydown', oKeydownEvent) |
| 289 | $search.unbind('input', oInputEvent) |
| 290 | $search.on('input', function(e) { |
| 291 | oInputEvent(e) |
| 292 | $('.search-item:last').attr('href', 'https://www.sov2ex.com/?q=' + $search.val()).text('sov2ex ' +$search.val()); |
| 293 | }) |
| 294 | $search.keydown(function(e) { |
| 295 | if (e.code == 'Enter' || e.code == 'NumpadEnter' || e.keyCode === 13) { |
| 296 | if ($('.search-item:last').is('.active')) { |
| 297 | $(this).val($(this).val().replace(/[#%&]/g,""));//用户输入不能包含特殊字符#%& |
| 298 | window.open("https://www.sov2ex.com/?q=" + $(this).val()); |
| 299 | return 0 |
| 300 | } |
| 301 | } |
| 302 | oKeydownEvent(e) |
| 303 | }) |
| 304 | `; |
| 305 | } |
| 306 | |
| 307 | |
| 308 | // 回到顶部(右键左右两侧空白处) |
nothing calls this directly
no outgoing calls
no test coverage detected