Greasy Fork is available in English.

Webnovel Tag Search Mode Switcher

This script simplifies tag searches on Webnovel.com, allowing you to switch between novel and fanfic search modes, eliminating the need for manual URL adjustments. Enhance your tag exploration experience with this user-friendly feature.

// ==UserScript==
// @name        Webnovel Tag Search Mode Switcher
// @namespace   https://greasyfork.org/en/users/1200276-awesome4
// @version     1.0
// @description This script simplifies tag searches on Webnovel.com, allowing you to switch between novel and fanfic search modes, eliminating the need for manual URL adjustments. Enhance your tag exploration experience with this user-friendly feature.
// @author      Awesome
// @match       https://www.webnovel.com/*
// @grant       none
// @license     GNU GPLv3
// @name:en     Webnovel Tag Search Mode Switcher
// @name:es     Interruptor de Modo de Búsqueda de Etiquetas en Webnovel
// @name:ar     مبدل وضع البحث في العلامات على ويب نوفل
// @name:fr     Commutateur de Mode de Recherche d'Étiquettes Webnovel
// @name:de     Webnovel Tag-Suchmodus-Umschalter
// @name:it     Interruttore di Modalità di Ricerca di Etichette Webnovel
// @name:ru     Переключатель режима поиска по меткам на Webnovel
// @name:zh-CN  Webnovel标签搜索模式切换器
// @name:zh-TW  Webnovel標籤搜索模式切換器
// @name:ja     Webnovelタグ検索モード切替機能
// @name:pt     Alternador de Modo de Pesquisa de Tags no Webnovel
// @name:tr     Webnovel Etiket Arama Modu Değiştirici
// @name:hi     वेबनोवेल टैग खोज मोड स्विचर
// @description:en This script simplifies tag searches on Webnovel.com, allowing you to switch between novel and fanfic search modes, eliminating the need for manual URL adjustments. Enhance your tag exploration experience with this user-friendly feature.
// @description:es Este script simplifies tag searches on Webnovel.com, allowing you to switch between novel and fanfic search modes, eliminating the need for manual URL adjustments. Enhance your tag exploration experience with this user-friendly feature.
// @description:ar هذا البرنامج النصي يبسط عمليات البحث في العلامات على موقع ويب نوفل، مما يتيح لك التبديل بين أوضاع البحث في الروايات وقصص المشجعين، والتخلص من الحاجة إلى تعديل الروابط يدويًا. قم بتعزيز تجربتك في استكشاف العلامات مع هذه الميزة سهلة الاستخدام.
// @description:fr Ce script simplifies tag searches on Webnovel.com, allowing you to switch between novel and fanfic search modes, eliminating the need for manual URL adjustments. Enhance your tag exploration experience with this user-friendly feature.
// @description:de Dieses Skript vereinfacht die Tag-Suchfunktion auf Webnovel.com, es ermöglicht Ihnen, zwischen den Suchmodi für Romane und Fanfictions zu wechseln und eliminiert die Notwendigkeit für manuelle URL-Anpassungen. Verbessern Sie Ihre Tag-Erforschungserfahrung mit dieser benutzerfreundlichen Funktion.
// @description:it Questo script semplifica le ricerche delle etichette su Webnovel.com, permettendoti di passare tra le modalità di ricerca di romanzi e fanfiction, eliminando la necessità di aggiustamenti manuali dell'URL. Potenzia la tua esperienza di esplorazione delle etichette con questa funzionalità user-friendly.
// @description:ru Этот скрипт упрощает поиск по меткам на Webnovel.com, позволяя вам переключаться между режимами поиска романов и фанфиков, исключая необходимость вручную изменять URL. Улучшите вашу эксплорацию тегов с помощью этой простой в использовании функции.
// @description:zh-CN 这个脚本简化了Webnovel.com上的标签搜索,使您可以轻松切换小说和同人文的搜索模式,无需手动调整URL。使用这个用户友好的功能来增强您的标签探索体验。
// @description:zh-TW 這個腳本簡化了Webnovel.com上的標籤搜索,使您可以輕鬆切換小說和同人文的搜索模式,無需手動調整URL。增強您的標籤探索體驗與這個用戶友好的功能。
// @description:ja このスクリプトはWebnovel.comでのタグ検索を簡素化し、小説とファンフィクションの検索モードを切り替え、URLの手動調整の必要性をなくします。ユーザーフレンドリーなこの機能でタグの探索体験を向上させてください。
// @description:pt Este script simplifica as pesquisas por tags no Webnovel.com, permitindo que você alterne entre os modos de pesquisa de romances e fanfics, eliminando a necessidade de ajustes manuais de URL. Melhore sua experiência de exploração de tags com este recurso amigável ao usuário.
// @description:tr Bu betik, Webnovel.com'daki etiket aramalarını basitleştirir ve roman ve fanfiksiyon arama modları arasında kolayca geçiş yapmanıza olanak tanır, böylece URL ayarlarını manuel olarak yapma ihtiyacını ortadan kaldırır. Bu kullanıcı dostu özellikle etiket keşif deneyiminizi geliştirin.
// @description:hi यह स्क्रिप्ट वेबनोवेल.कॉम पर टैग खोजों को सरल बनाता है, जिससे आप उपन्यास और फैनफिक खोज मोड्स के बीच आसानी से स्विच कर सकते हैं, URL समीक्षा की आवश्यकता को हटा देता है। इस उपयोगकर्ता-मित्र लिए अपने खोज अन्वेषण अनुभव को बेहतर बनाएं।
// ==/UserScript==



(function() {
    'use strict';

    // Get the genre name from the page
    const genreName = document.querySelector('h2.lh1\\.5').textContent;

    // Check if the current URL matches the expected pattern
    const url = window.location.href;
    const isNovelPage = url.includes(`/tags/${genreName}-novel`);
    const isFanficPage = url.includes(`/tags/${genreName}-fanfic`);

    // Check if the page is a genre-specific page
    if (isNovelPage || isFanficPage) {
        // Create a button element with the appropriate text
        const buttonText = isNovelPage ? `${genreName} Fanfics` : `${genreName} Novels`;
        const button = document.createElement('button');
        button.textContent = buttonText;

// Include the web font in the head of the document
const head = document.getElementsByTagName('head')[0];
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'https://fonts.googleapis.com/css2?family=Archivo:wght@400;700&display=swap';
head.appendChild(link);

// Wait for the font to load before creating the button
link.addEventListener('load', function() {
    // Create the button element with the appropriate text
    const buttonText = isNovelPage ? `${genreName} Fanfics` : `${genreName} Novels`;
    const button = document.createElement('button');
    button.textContent = buttonText;

    // Add your custom functionality to the button here
    button.addEventListener('click', function() {
        // Redirect to the other page based on the current page
        const newUrl = isNovelPage ? url.replace('-novel', '-fanfic') : url.replace('-fanfic', '-novel');
        window.location.href = newUrl;
    });

    // Add CSS styles to the button to make it look like the original button
    button.style.display = 'inline-block';
    button.style.padding = '8px 16px';
    button.style.paddingBottom = '4px';
    button.style.border = 'none';
    button.style.borderRadius = '4px';
    button.style.borderBottomColor = 'rgba(0, 0, 0, 0)';
    button.style.borderBottomStyle = 'solid';
    button.style.borderBottomWidth = '1.75px';
    button.style.backgroundColor = 'transparent';
    button.style.color = 'rgb(131, 132, 143)';
    button.style.textDecorationColor = 'rgb(131, 132, 143)';
    button.style.textDecorationLine = 'none';
    button.style.textDecorationStyle = 'solid';
    button.style.textDecorationThickness = 'auto';
    button.style.fontFamily = 'Archivo, sans-serif';
    button.style.fontWeight = 'bold';
    button.style.fontSize = '20px';
    button.style.lineHeight = '30px';
    button.style.cursor = 'pointer';
    button.style.marginRight = '32px';
    button.style.overflowWrap = 'break-word';
    button.style.textTransform = 'capitalize';
    button.style.verticalAlign = 'bottom';
    button.style.whiteSpace = 'nowrap';

    button.addEventListener('mouseover', function() {
        button.style.backgroundColor = '#f5f5f5';
    });

    button.addEventListener('mouseout', function() {
        button.style.backgroundColor = 'transparent';
    });

    // Append the button to the page
    const nav = document.querySelector('.lst-nav');
    nav.appendChild(button);
});
    }
})();