瀏覽代碼

first commit

master
Jared 2 年之前
當前提交
026764374e
共有 1 個檔案被更改,包括 51 行新增0 行删除
  1. +51
    -0
      BraveSearchPlus.user.js

+ 51
- 0
BraveSearchPlus.user.js 查看文件

@@ -0,0 +1,51 @@
// ==UserScript==
// @name Brave Search Plus
// @namespace https://ikibani.com
// @version 0.1
// @description Supercharge the Brave search engine.
// @author afycyro
// @match https://search.brave.com/
// @match https://search.brave.com/search?q=*
// @icon https://www.google.com/s2/favicons?sz=64&domain=brave.com
// @grant none
// ==/UserScript==

(function() {
'use strict';

let search = {
origTerms: "",
terms: "",
exclude: [],
}

const searchBox = document.querySelector('input#searchbox');

document.querySelector('form.form').addEventListener('submit', () => {
let searchValue = searchBox.value.trim();
search.origTerms = searchValue;
searchValue = searchValue.toLowerCase().split(' ').filter(t => !t.startsWith('-')).join(' ');

search.exclude = searchBox.value.split(' ').filter(term => term.startsWith('-')).map(term => term.slice(1));
search.terms = searchValue;
window.localStorage.setItem('searchOptions', JSON.stringify(search));
searchBox.value = search.terms;

return true;
});

if (window.location.href.split('/').filter(c => !!c).length > 2) {
search = JSON.parse(window.localStorage.getItem('searchOptions'));
searchBox.value = search.origTerms;
document.querySelector('head title').innerText = `${search.origTerms} - Brave Search`
const results = document.querySelectorAll('.snippet.fdb');
for (let result of results) {
let resultLoc = result.querySelector('.netloc');
for (let exclusion of search.exclude) {
if (resultLoc.innerText.toLowerCase().includes(exclusion)) {
result.style.display = 'none';
}
}
};
}
})();

Loading…
取消
儲存