Komica WebM linker

webm linker

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Komica WebM linker
// @namespace    http://tampermonkey.net/
// @version      2.0.3
// @description  webm linker
// @author       72
// @include      https://*.komica.org/00*/pixmicat.php?mode=category&c=WebM*
// @grant        none
// @license      WTFPL
// ==/UserScript==

(function()
{
    'use strict';

    var No = document.querySelectorAll('.qlink'); //find Post No.

    for(var i=0; i<No.length; i++)
    {

        var num = No[i].textContent.replace("No.",""); //Delete prefix

        let button = document.createElement("button"); //create button

        var link = document.createElement("a"); //create link

        var link2 = document.createElement("b"); //create link for search

        link.setAttribute('href','pixmicat.php?res='+num); //set link
        link.setAttribute('target','_blank'); //set link to open in new tab
        link.innerHTML = "試圖前往原串"; //set link

        link2.setAttribute('href','pixmicat.php?mode=search'); //set link2

        button.innerHTML = "搜尋原串"; //set button
        button.name = num; //name every button to let clipboard can have things to copy

        document.getElementsByClassName('post-head')[i].appendChild(link); //add link
        document.getElementsByClassName('post-head')[i].appendChild(button); //add button

        button.onclick = function () //set onclick movement
        {
           /* navigator.clipboard.writeText(button.name).then( //copy to clipboard

            function()
            {*/
                var new_window = window.open('pixmicat.php?mode=search','_blank'); //open search page
                new_window.onload = function ()
                {
                let Number = new_window.document.getElementsByName("keyword"); //get keyword input form
                Number[0].value = button.name; //auto fill-in search Number

                new_window.document.querySelector('select[name="field"]').value = "no"; //auto select search target to number
                };
           /* },
                                                            function()
            {
                alert('Error'); //if fail
            });*/


        }

    }


})();