// ==UserScript== // @name YouTube Lyrics // @namespace http://userscripts.org/users/28612 // @version 3.04.00 // @changes Fixed the parsing of the video category,Added the "movies" video category // @description Adds a lyrics box to the YouTube sidebar under the video informations box. It can search in twelve different lyrics sites and it shows also all the results in a drop down. // @include http://*youtube.com/watch?* // @require http://userscripts.org/scripts/version/33024/88773.user.js // @resource Library1Resources http://www.fileden.com/files/2008/9/2/2077873/JavascriptLibrary/0_5_0/Library1.xml // @resource Library1Resources_de http://www.fileden.com/files/2008/9/2/2077873/JavascriptLibrary/0_5_0//Library1_de.xml // @resource Library1Resources_es http://www.fileden.com/files/2008/9/2/2077873/JavascriptLibrary/0_5_0/Library1_es.xml // @resource Library1Resources_fr http://www.fileden.com/files/2008/9/2/2077873/JavascriptLibrary/0_5_0/Library1_fr.xml // @resource Library1Resources_it http://www.fileden.com/files/2008/9/2/2077873/JavascriptLibrary/0_5_0/Library1_it.xml // @resource YoutubeLyricsResources http://www.fileden.com/files/2008/9/2/2077873/YoutubeLyrics/3_4_0/YoutubeLyrics.xml // @resource YoutubeLyricsResources_de http://www.fileden.com/files/2008/9/2/2077873/YoutubeLyrics/3_4_0/YoutubeLyrics_de.xml // @resource YoutubeLyricsResources_es http://www.fileden.com/files/2008/9/2/2077873/YoutubeLyrics/3_4_0/YoutubeLyrics_es.xml // @resource YoutubeLyricsResources_fr http://www.fileden.com/files/2008/9/2/2077873/YoutubeLyrics/3_4_0/YoutubeLyrics_fr.xml // @resource YoutubeLyricsResources_it http://www.fileden.com/files/2008/9/2/2077873/YoutubeLyrics/3_4_0/YoutubeLyrics_it.xml // @resource LyricsSitesDefinitions http://userscripts.org/scripts/source/34831.user.js // ==/UserScript== var ScriptInfos={ id: 22569, name: "Youtube Lyrics", version: new Version("3.04.00"), language: "en", idPrefix: "YL" } var CM=null var RM=null; var SU=null; var DU=null; init(); function init() { CM=new ConfigurationManager(); RM=new ResoucesManager(); SU=new Updater(22569,"Youtube Lyrics","updater","//div[@id='YLLyricsPanel']"); DU=new Updater(34831,"Definitions","definitions","//div[@id='YLLyricsPanel']",installDefinitions); if (ScriptInfos.version.compareTo(CM.config.updater && CM.config.updater.version)==1) updateOptions(); ScriptInfos.language=CM.config.language; ScriptInfos.requestsCounter=0; $rmc("MenuOptions",[ScriptInfos.name],showOptionsPanel); var text1=getVideoCategory(); GM_log(text1); if (CM.config.showOnCategory==text1 || ($isa(CM.config.showOnCategory) && CM.config.showOnCategory.contains(text1))) initLyricsPanel(); else if (CM.config.addUserScriptCommandToShowLyricsPanel) $rmc("MenuShow",[ScriptInfos.name],initLyricsPanel); } function updateOptions() { var obj1={ language:"en", showSendFeedbackConfirm:"on", updater:{ lastCheckDate:new Date(), checkFrequency:1}, showOnCategory:"10", addUserScriptCommandToShowLyricsPanel:"on", showAlertOnSavePreferred:"on", showSearchTextBox:"on", showResultsDropDown:"on", showLinkOriginalPage:"on", showLinkSearchYoutube:"on", showLinkSendParsingError:"on", showSendParsingErrorConfirm:"on", preferredSite:"", activeSites:[], definitions:{ autoInstall:"on", lastCheckDate:new Date(), checkFrequency:1}, lyricsSitesDefinitions:[] }; $mo(obj1,CM.config); obj1.updater.version=ScriptInfos.version; var text1=GM_getResourceText("LyricsSitesDefinitions"); obj1.definitions.version=new Version(/version.*?((?:\.|\d)+)/gm.exec(text1)[1]); mergeLyricsSitesDefinitions(obj1,$t2o(text1)); setOptions(obj1); } function mergeLyricsSitesDefinitions(config,obj1) { var array1=new Array(); var obj2=config.lyricsSitesDefinitions; for(var num1=0;num1/gmi,"")]); match1=ScriptInfos.lyricsSite.parseListRegexp.exec(response.responseText); } if (ScriptInfos.lyricsLinks.length!=0) loadLyricsPage(0); else { setLyricsDivContent(RM.getText("FoundNothing",ScriptInfos.lyricsSite.name),false,CM.config.showSearchTextBox); // mallo // ++ toggleExpand(showLink=false); // ++ } } function loadLyricsPage(index) { ScriptInfos.lyricsLinksIndex=index; setLyricsDivContent(RM.getText("Loading",[ScriptInfos.lyricsSite.name,ScriptInfos.lyricsLinks[index][1]]),true,CM.config.showSearchTextBox,CM.config.showResultsDropDown,CM.config.showLinkOriginalPage,CM.config.showLinkSearchYoutube); sendLyricsRequest(ScriptInfos.lyricsLinks[index][0],parseLyricsPage,ScriptInfos.lyricsSite.lyricsEncoding); } function parseLyricsPage(response) { var text1=""; var flag1=false; if (response.status!=200) { flag1=true; text1=RM.getText("LyricsParsingErrorHTML",[response.statusText,""]); } else { //GM_log(response.responseText); var array1=ScriptInfos.lyricsSite.parseLyrics; for(var num1=0;num1/gmi,""); if (response.responseText.match(/<\/pre>/gmi)) text3=text3.replace(/\n/gmi,"
").replace(/\r/gmi,""); text3=text3.replace(/
/gmi,"
").replace(/(?:\s*)+/gmi,"
").replace(/^\s*(?:\s*)+/gi,""); text1=RM.getText("LyricsParsingSuccessHTML",[ScriptInfos.idPrefix,text2,text3]); break; } } if (!text1) { flag1=true; text1=RM.getHTMLTexts("LyricsParsingError"); } } setLyricsDivContent(text1,false,CM.config.showSearchTextBox,CM.config.showResultsDropDown,CM.config.showLinkOriginalPage,CM.config.showLinkSearchYoutube,CM.config.showLinkSendParsingError && flag1); } function showOptionsPanel(reset) { var div1=addModalDiv(hideOptions); var div2=addOptionsPanel(reset); setFormValues($idp("OptionsForm"),CM.config); $idp("EditLyricsSitesDefinitions").disabled=false; with($idp("LyricsSitesDefinitions")) { readOnly=true; disabled=true; } div1.className=""; div2.className=""; ScriptInfos.optionsPanelVisible=true; } function addOptionsPanel(reset) { var div1=$idp("OptionsContainer"); if (div1 && reset) {div1.parentNode.removeChild(div1); div1=null;} if (div1==null) { addStyle("OptionsContainerStyle"); addNoPaddedListStyle(); var array1=new Array(); array1.push(RM.getHTMLTexts("OptionsGeneral",[ScriptInfos.idPrefix,,,,,,,,,,SU.homepageUrl])); array1.push(RM.getHTMLTexts("OptionsUpdater")); array1.push(RM.getHTMLTexts("OptionsDisplay")); array1.push(RM.getHTMLTexts("OptionsLyricsPanelContent")); array1.push(RM.getHTMLTexts("OptionsLyricsSites")); array1.push(RM.getHTMLTexts("OptionsLyricsSitesDefinitions")); div1=stringToHTML(RM.getHTMLTexts("OptionsContainer",[ScriptInfos.idPrefix,RM.getHTMLTexts("OptionsLeftSide",[ScriptInfos.idPrefix,ScriptInfos.name]),array1.join("\n")])); document.body.appendChild(div1); var li1=$idp("OptionsLyricsSites"); var ul1=li1.parentNode; ul1.removeChild(li1); for(var num1=0;num1