PDF search on Google

Adds a button to search PDF with Google

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         PDF search on Google
// @version      1.0.0
// @description  Adds a button to search PDF with Google
// @author       Mario O.M. and D.V
// @namespace    https://github.com/marioortizmanero/reddit-search-on-google/
// @include      http*://www.google.*/search*
// @include      http*://google.*/search*
// @run-at       document-end
// @license MIT
// ==/UserScript==
// Creating the element
let el = document.createElement('div');
el.className = 'hdtb-mitem';
const link = document.createElement('a');

// Adding the svg icon
if (useIcon) {
    const span = document.createElement('span');
    span.className = isImageSearch ? 'm3kSL' : 'bmaJhd iJddsb';
    span.style.cssText = 'height:16px;width:16px';
    span.innerHTML = redditIcon;
    link.appendChild(span);
}

// Hyperlink to add 'site:reddit.com' to the query
link.appendChild(document.createTextNode('PDF'));

// Agregar un menú desplegable
const menu = document.createElement('ul');
menu.id = 'pdf-menu';
menu.style.display = 'none';
const menuItems = ['Opción 1', 'Opción 2', 'Opción 3'];
menuItems.forEach((item) => {
  const menuItem = document.createElement('li');
  const menuItemLink = document.createElement('a');
  menuItemLink.href = '#';
  menuItemLink.innerText = item;
  menuItem.appendChild(menuItemLink);
  menu.appendChild(menuItem);
});
el.appendChild(menu);

link.addEventListener('mouseover', () => {
  menu.style.display = 'block';
});

link.addEventListener('mouseout', () => {
  menu.style.display = 'none';
});

// Reemplazar el enlace original
link.href = window.location.href.replace(queryRegex, (match) => {
    // Replaces the existing `site` flags
    return match.search(siteRegex) >= 0 ? match.replace(siteRegex, redditUrl) : match + redditUrl;
});

if (isImageSearch) {
    link.classList.add('NZmxZe');
    el = link;
} else {
    el.appendChild(link);
}

// Inserting the element into Google search
if (appendRight) {
    const toolsBtn = document.querySelector(isImageSearch ? '.ssfWCe' : '.t2vtad');
    toolsBtn.parentNode.insertBefore(el, toolsBtn.nextSibling);
} else {
    const menuBar = document.querySelector(isImageSearch ? '.T47uwc' : '.MUFPAc');
    if (isImageSearch) {
        menuBar.insertBefore(el, menuBar.children[menuBar.childElementCount - 1]);
    } else {
        menuBar.appendChild(el);
    }
}