Search Reelgood

Context menu to execute UserScript

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name            Search Reelgood
// @namespace       http://tampermonkey.net/
// @description     Context menu to execute UserScript
// @version         0.20
// @author          [email protected]
// @include         *
// @grant           GM_openInTab
// @run-at          context-menu
// @license         GPL 2.0
// @description     allows a one click connection from any website to the Reelgood search results for that selection
// ==/UserScript==]]


(function() {
    'use strict';
    //first read any selected text
    var textSelected = "";
        textSelected = document.getSelection().toString().trim();

    //if none, read text under cursor
    if(textSelected.length<=1){
        var elements = document.querySelectorAll(':hover');
        textSelected = elements[elements.length-1].innerText.trim();
        console.log(elements.length+"  "+elements);
    }
    //convert non url safe characters
    //var urlsafe = textSelected.replace("&", "%26"); //textSelected = ";,/?:@&=+$-_.!~*'()#"
    var urlsafe = encodeURIComponent(textSelected);
    console.log("RightClickTo ---"+textSelected+"---"+ urlsafe );
    GM_openInTab("https://reelgood.com/search?q="+urlsafe, { active: true, insert: true, setParent: true });

})();