🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2025/12/27 09:28:54
🔄 下次更新时间:2025/12/27 10:28:54
手动刷新缓存

GitHub Files Icon Replacement

Replace GitHub file icons with Material icons

Version au 25/12/2024. Voir la dernière version.

Vous devrez installer une extension telle que Tampermonkey, Greasemonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Userscripts pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey pour installer ce script.

Vous devrez installer une extension de gestionnaire de script utilisateur pour installer ce script.

(J'ai déjà un gestionnaire de scripts utilisateur, laissez-moi l'installer !)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

(J'ai déjà un gestionnaire de style utilisateur, laissez-moi l'installer!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         GitHub Files Icon Replacement
// @name:vi      Thay thế biểu tượng tệp GitHub
// @name:zh-cn   GitHub 文件图标替换
// @name:zh-tw   GitHub 文件圖標替換
// @name:ru      Замена иконок файлов GitHub
// @namespace    http://tampermonkey.net/
// @version      2024.12.25.1
// @description  Replace GitHub file icons with Material icons
// @description:vi  Thay thế icon file trên GitHub bằng icon Material
// @description:zh-cn  用更漂亮的图标替换 GitHub 文件图标
// @description:zh-tw  用更漂亮的圖標替換 GitHub 文件圖標
// @description:ru  Замена иконок файлов GitHub на более красивые
// @author       Yuusei
// @match        https://github.com/*
// @icon         https://github.githubassets.com/favicon.ico
// @grant        GM_addStyle
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @run-at       document-start
// @license      GPL-3.0-only
// @compatible   chrome
// @compatible   firefox
// @compatible   edge
// @compatible   safari
// ==/UserScript==

(function($) {
    'use strict';

    // Add custom styles
    GM_addStyle(`
        .material-icon {
            width: 20px;
            height: 20px;
            vertical-align: text-bottom;
            margin-right: 4px;
            transition: transform 0.2s ease;
        }
        .material-icon:hover {
            transform: scale(1.2);
        }
    `);

    const iconMap = {
        // Development
        '.ts': 'typescript',
        '.tsx': 'react_ts', 
        '.js': 'javascript',
        '.jsx': 'react',
        '.py': 'python',
        '.java': 'java',
        '.cpp': 'cpp',
        '.c': 'c',
        '.cs': 'csharp',
        '.go': 'go',
        '.rb': 'ruby',
        '.php': 'php',
        '.rs': 'rust',
        '.swift': 'swift',
        '.kt': 'kotlin',
        '.kts': 'kotlin',
        '.scala': 'scala',
        '.dart': 'dart',
        '.lua': 'lua',
        '.r': 'r',
        '.pl': 'perl',
        '.sh': 'shell',
        '.ps1': 'powershell',
        '.bat': 'console',
        '.cmd': 'console',
        '.asm': 'assembly',
        '.s': 'assembly',
        '.wasm': 'assembly',
        '.code-workspace': 'vscode',
        '.sln': 'visualstudio',
        '.csproj': 'visualstudio',
        '.vbproj': 'visualstudio',
        '.vcxproj': 'visualstudio',
        '.fsproj': 'visualstudio',

        // Web
        '.html': 'html',
        '.htm': 'html',
        '.css': 'css',
        '.scss': 'sass',
        '.sass': 'sass',
        '.less': 'less',
        '.styl': 'stylus',
        '.vue': 'vue',
        '.svelte': 'svelte',
        '.angular': 'angular',
        '.ember': 'ember',

        // Data & Config
        '.json': 'json',
        '.yml': 'yaml', 
        '.yaml': 'yaml',
        '.xml': 'xml',
        '.toml': 'settings',
        '.ini': 'settings',
        '.env': 'tune',
        '.conf': 'settings',
        '.sql': 'database',
        '.db': 'database',
        '.sqlite': 'database',
        '.graphql': 'graphql',
        '.proto': 'protobuf',

        // Documentation
        '.md': 'markdown',
        '.mdx': 'markdown',
        '.txt': 'document',
        '.pdf': 'pdf',
        '.doc': 'word',
        '.docx': 'word',
        '.odt': 'document',
        '.rtf': 'document',

        // Images
        '.svg': 'svg',
        '.png': 'image',
        '.jpg': 'image',
        '.jpeg': 'image',
        '.gif': 'image',
        '.ico': 'image',
        '.webp': 'image',
        '.bmp': 'image',
        '.tiff': 'image',

        // Media
        '.mp3': 'audio',
        '.wav': 'audio',
        '.ogg': 'audio',
        '.mp4': 'video',
        '.webm': 'video',
        '.avi': 'video',
        '.mov': 'video',
        '.wmv': 'video',

        // Archives
        '.zip': 'zip',
        '.rar': 'zip',
        '.7z': 'zip',
        '.tar': 'zip',
        '.gz': 'zip',
        '.bz2': 'zip',

        // System
        '.exe': 'exe',
        '.dll': 'dll',
        '.so': 'lib',
        '.dylib': 'lib',
        '.sys': 'windows',
        '.reg': 'windows',

        // Design
        '.fig': 'figma',
        '.sketch': 'sketch',
        '.ai': 'illustrator',
        '.psd': 'photoshop',
        '.xd': 'xd',

        // 3D & Game
        '.unity': 'unity',
        '.blend': 'blender',
        '.fbx': '3d',
        '.obj': '3d',
        '.gltf': '3d',
        '.uasset': 'unreal',
        '.upk': 'unreal',

        // Mobile
        '.apk': 'android',
        '.ipa': 'apple',
        '.xcodeproj': 'xcode',
        '.pbxproj': 'xcode',
        
        // Container & Cloud
        '.dockerfile': 'docker',
        '.dockerignore': 'docker',
        '.tf': 'terraform',
        '.tfvars': 'terraform',
        '.vagrant': 'vagrant',
        '.helm': 'kubernetes',
        
        // Other
        '.vim': 'vim',
        '.emacs': 'emacs',
        '.gradle': 'gradle',
        '.maven': 'maven',
        '.cargo': 'rust'
    };

    const specialFiles = {
        // Package managers
        'package.json': 'nodejs',
        'package-lock.json': 'nodejs',
        'yarn.lock': 'yarn',
        'pnpm-lock.yaml': 'pnpm',
        'bun.lockb': 'bun',
        'composer.json': 'composer',
        'composer.lock': 'composer',
        'Gemfile': 'ruby',
        'Gemfile.lock': 'ruby',
        'requirements.txt': 'python',
        'poetry.lock': 'python',
        'Cargo.toml': 'rust',
        'Cargo.lock': 'rust',

        // Config files
        'tsconfig.json': 'typescript',
        '.eslintrc': 'eslint',
        '.prettierrc': 'prettier',
        '.editorconfig': 'editorconfig',
        'webpack.config.js': 'webpack',
        'vite.config.js': 'vite',
        'rollup.config.js': 'rollup',
        'babel.config.js': 'babel',
        'jest.config.js': 'jest',
        'karma.conf.js': 'karma',
        'cypress.config.js': 'cypress',
        'playwright.config.js': 'playwright',

        // Documentation
        'README.md': 'markdown',
        'LICENSE': 'certificate',
        'CHANGELOG.md': 'markdown',
        'CONTRIBUTING.md': 'markdown',

        // Git
        '.gitignore': 'git',
        '.gitattributes': 'git',
        '.gitmodules': 'git',
        '.gitmessage': 'git',
        '.gitkeep': 'git',

        // CI/CD
        '.travis.yml': 'travis',
        '.gitlab-ci.yml': 'gitlab',
        'Jenkinsfile': 'jenkins',
        'azure-pipelines.yml': 'azure',
        'bitbucket-pipelines.yml': 'bitbucket',

        // Docker
        'Dockerfile': 'docker',
        'docker-compose.yml': 'docker',
        'docker-compose.yaml': 'docker',
        'docker-compose.override.yml': 'docker',

        // Framework configs
        'angular.json': 'angular',
        'next.config.js': 'next',
        'nuxt.config.js': 'nuxt',
        'svelte.config.js': 'svelte',
        'capacitor.config.json': 'capacitor',
        'ionic.config.json': 'ionic',

        // Build tools
        'Makefile': 'makefile',
        'CMakeLists.txt': 'cmake',
        'build.gradle': 'gradle',
        'pom.xml': 'maven',
        'build.sbt': 'sbt',

        // Environment
        '.env': 'tune',
        '.env.local': 'tune',
        '.env.development': 'tune',
        '.env.production': 'tune',
        '.env.test': 'tune',

        // Version managers
        '.nvmrc': 'nodejs',
        '.node-version': 'nodejs',
        '.ruby-version': 'ruby',
        '.python-version': 'python',
        '.java-version': 'java'
    };

    function replaceIcons() {
        $('.react-directory-row-name-cell-large-screen').each(function() {
            const $filenameElement = $(this).find('.react-directory-filename-cell');
            
            if ($filenameElement.length) {
                const filename = $filenameElement.text();
                let iconName = specialFiles[filename];

                if (!iconName) {
                    const extension = Object.keys(iconMap).find(ext => 
                        filename.toLowerCase().endsWith(ext)
                    );
                    iconName = extension ? iconMap[extension] : null;
                }

                if (iconName) {
                    const $oldSvg = $(this).find('svg');
                    if ($oldSvg.length) {
                        const $newIcon = $('<img>', {
                            src: `https://raw.githubusercontent.com/material-extensions/vscode-material-icon-theme/refs/heads/main/icons/${iconName}.svg`,
                            class: 'material-icon',
                            alt: iconName
                        });
                        $oldSvg.replaceWith($newIcon);
                    }
                }
            }
        });
    }

    // Initial replacement
    $(document).ready(replaceIcons);

    // Watch for DOM changes
    const observer = new MutationObserver(replaceIcons);
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

})(jQuery);