Jared 2 лет назад
Сommit
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';
}
}
};
}
})();

Загрузка…
Отмена
Сохранить