github-search-helper

在新标签页打开github搜索,explore和trending结果

Version vom 26.07.2024. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         github-search-helper
// @namespace    github.com/leychan
// @version      0.2
// @description  在新标签页打开github搜索,explore和trending结果
// @author       leychan
// @match        https://github.com/trending
// @match        https://github.com/explore
// @match        https://github.com/search*
// @icon         https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png
// @run-at document-end
// @grant        none
// @license       MIT
// ==/UserScript==

(function() {
    'use strict';

    const observer = new MutationObserver((mutationsList, observer) => {
        const element = document.querySelector('[data-testid="results-list"]');
        if (element) {
            let allSearchResultATag = element.getElementsByTagName('a')
            for (let i = 0 ;i < allSearchResultATag.length; i++) {
                allSearchResultATag[i].setAttribute('target', '_blank')
                console.log(allSearchResultATag[i])
            }
            observer.disconnect(); // 停止观察
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });


    let allExploreResultATag = document.getElementsByTagName('a')
    for (let i = 0 ;i < allExploreResultATag.length; i++) {
        allExploreResultATag[i].setAttribute('target', '_blank')
    }

    let allTrendingResultATag = document.getElementsByTagName('a')
    for (let i = 0 ;i < allTrendingResultATag.length; i++) {
        allTrendingResultATag[i].setAttribute('target', '_blank')
    }
  })();