Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ecosia で邪魔なサイトを結果から除外するスクリプト

Last updated at Posted at 2022-03-07

tampermonkyを入れて, スクリプトを追加する.

// ==UserScript==
// @name         Block Noisy Site on Ecosia
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  remove noisy sites from search result of Ecosia
// @match        https://www.ecosia.org/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        none
// @require    http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';
    $(document).ready(function(){
      let blocklist = [
        //ここに邪魔なサイトのURLの正規表現を列挙する ,
      ];
      $(".mainline")
          .find(".mainline__result-wrapper")
          .find("article")
          .toArray().forEach( e => {
              let reg = RegExp('<a.+?</a>');
              if(reg.exec(e.innerHTML) !== null){
              e.innerHTML.match('<a.+?</a>').forEach( v => {
                  let link_url = v.match('"https?://.*?"');
                  blocklist.forEach( b => {
                      let block_reg = new RegExp(b);
                      let result = block_reg.exec(link_url);
                      if (result !== null) {
                        e.remove();
                      }
                  });
              })
            }
    });
  });
})();
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?