Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name GoogleGroovesharkBar
- // @description Adds a 'Search on Grooveshark' option to Google's black navigation bar
- // @include google.com/*
- // @include google.nl/*
- // @include https://www.google.com/*
- // @include https://www.google.nl/*
- // @include http://www.google.com/*
- // @include http://www.google.nl/*
- // @require http://code.jquery.com/jquery-1.10.1.min.js
- //by Soullesswaffle
- //Versions : 0.8
- // ==/UserScript==
- function addGroove(retrievedText) {
- var bar = document.getElementById("gbzc");
- var grooveyImage = document.createElement("img");
- var link = document.createElement("a");
- var listy = document.createElement("li");
- grooveyImage.src = "http://cdn.androidpolice.com/wp-content/uploads/2012/08/nexusae0_146.png";
- grooveyImage.style.height = "28px";
- //grooveyImage.alt doesn't display in chrome for me, but when inspecting the element the alt attribute is present and correct.
- if (retrievedText === "") {
- link.href = "http://grooveshark.com";
- grooveyImage.alt = "Grooveshark";
- } else {
- link.href = "http://grooveshark.com/#!/search?q=" + retrievedText;
- grooveyImage.alt = "Search for '" + retrievedText + "' on Grooveshark";
- }
- //Nest and display everything
- link.appendChild(grooveyImage);
- listy.appendChild(link);
- listy.id = "grvshrkbtn";
- if (!document.getElementById("grvshrkbtn")) {
- bar.appendChild(listy);
- } else {
- bar.replaceChild(listy, document.getElementById("grvshrkbtn"));
- }
- }
- //Initialize
- $(document).ready(function () {
- addGroove(document.getElementById("gbqfq").value);
- });
- //Watch textfield for changes
- $("#gbqfq").bind("input", function () {
- addGroove($(this).val());
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement