NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @namespace https://openuserjs.org/users/mrbl // @name Coub Search buttons // @description Adds search buttons to coub.com (search by preview) // @copyright 2019, mrbl (https://openuserjs.org/users/mrbl) // @license MIT // @version 0.1.6 // @include *://coub.com/* // @include *://coubify.info/?coubId=* // @run-at document-body // @updateURL https://openuserjs.org/meta/mrbl/Coub_Search_buttons.meta.js // @downloadURL https://openuserjs.org/install/mrbl/Coub_Search_buttons.user.js // ==/UserScript== // ==OpenUserJS== // @author mrbl // ==/OpenUserJS== if(window.location.hostname == "coubify.info") { document.getElementById("coubIdInput").value = new URL(window.location.href).searchParams.get("coubId"); recognizeCoubAjax(); } var btnsStyle = document.createElement("style"); var head = document.head || document.getElementsByTagName('head')[0]; var css = ".csb img {width: 18px; height: 18px; margin-right: 5px; vertical-align: middle;} "; btnsStyle.type = "text/css"; btnsStyle.appendChild(document.createTextNode(css)); head.appendChild(btnsStyle); var icons = { "Google":"https://www.google.com/s2/favicons?domain=google.com", "Yandex":"https://www.google.com/s2/favicons?domain=yandex.com", "IQDB":"https://www.google.com/s2/favicons?domain=iqdb.org", "TinEye":"https://www.google.com/s2/favicons?domain=tineye.com", "tracemoe":"https://www.google.com/s2/favicons?domain=trace.moe", "SauceNAO":"https://www.google.com/s2/favicons?domain=saucenao.com", "Coubify":"https://www.google.com/s2/favicons?domain=coubify.info", "shiki":"https://www.google.com/s2/favicons?domain=shikimori.one" } function addButtons() { var coubsList = document.getElementsByClassName("coubs-list")[0]; var viewType = null; if(coubsList) viewType = coubsList.getAttribute("view"); if(viewType != "mosaic") { var coubs = document.getElementsByClassName("coub__vd"); for(var i=0; i<coubs.length; i++) { //debugger; if(coubs[i].getElementsByClassName("csb").length > 0) { continue; } else { var btns = document.createElement("span"); var img = coubs[i].getElementsByClassName("viewer__img")[0].src; let coubid = encodeURIComponent(coubsList?coubs[i].getElementsByClassName("description__title")[0].getElementsByTagName("A")[0].href:window.location.href); btns.className = "csb"; btns.innerHTML = "<a href='https://www.google.com/searchbyimage?image_url=" + img + "&safe=off' target='_blank' title='Google'><img src='" + icons.Google + "' alt='G'></a>"; btns.innerHTML += "<a href='https://yandex.com/images/search?url=" + img + "&rpt=imageview&safe=off' target='_blank' title='Yandex'><img src='" + icons.Yandex + "' alt='Y'></a>"; btns.innerHTML += "<a href='https://iqdb.org/?url=" + img + "' target='_blank' title='IQDB'><img src='" + icons.IQDB + "' alt='I'></a>"; btns.innerHTML += "<a href='https://www.tineye.com/search/?url=" + img + "' target='_blank' title='TinEye'><img src='" + icons.TinEye + "' alt='T'></a>"; btns.innerHTML += "<a href='https://trace.moe/?auto&url=" + img + "' target='_blank' title='Trace.moe (WhatAnime.ga)'><img src='" + icons.tracemoe + "' alt='W'></a>"; btns.innerHTML += "<a href='https://saucenao.com/search.php?url=" + img + "' target='_blank' title='SauceNAO'><img src='" + icons.SauceNAO + "' alt='S'></a>"; btns.innerHTML += "<a href='http://coubify.info/?coubId=" + coubid + "' target='_blank' title='Coubify'><img src='" + icons.Coubify + "' alt='C'></a>"; var parent = coubs[i].getElementsByClassName("description__stamp")[0]; parent.insertBefore(btns, parent.firstChild); } } } } addButtons(); var observer = new MutationObserver(function(mutations) { addButtons(); }); var config = { childList: true, subtree: true }; observer.observe(document.body, config);