// ==UserScript== // @name Vodafone Forum Improvements User Script // @version 3.0.0 // @namespace http://sites.google.com/site/manhinli/projects/vfforum/ // @description This modifies the Vodafone Forum website to allow it to stretch to wide monitors and introduce nifty little things // @include http://forum.vodafone.co.nz/* // @resource vfForumOnloadCSS http://iphone.nzconnection.net/vfforum/3.0/vff.firefox3.css // @resource vfForumJqueryUI http://iphone.nzconnection.net/vfforum/3.0/themes/smoothness/jquery-ui-1.7.1.custom.css // @require http://iphone.nzconnection.net/vfforum/3.0/jquery-1.3.2.min.js // @require http://iphone.nzconnection.net/vfforum/3.0/ui/ui.core.js // @require http://iphone.nzconnection.net/vfforum/3.0/ui/ui.dialog.js // @require http://iphone.nzconnection.net/vfforum/3.0/ui/ui.draggable.js // @require http://iphone.nzconnection.net/vfforum/3.0/ui/ui.droppable.js // @require http://iphone.nzconnection.net/vfforum/3.0/ui/ui.resizable.js // @require http://iphone.nzconnection.net/vfforum/3.0/ui/ui.selectable.js // @require http://iphone.nzconnection.net/vfforum/3.0/ui/ui.slider.js // @require http://iphone.nzconnection.net/vfforum/3.0/ui/ui.tabs.js // @require http://iphone.nzconnection.net/vfforum/3.0/jquery.cookie.js // @require http://iphone.nzconnection.net/vfforum/3.0/jquery.twitter.js // ==/UserScript== GM_log("***** BEFORE *****"); GM_log(GM_listValues()); /****************************************************************************************************/ /* DO NOT EDIT BELOW THIS LINE */ /****************************************************************************************************/ function addGlobalStyle(css) { var style; style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = css; document.getElementsByTagName('head')[0].appendChild(style); } /****************************************************************************************************/ /* Init of settings */ /****************************************************************************************************/ /* This is version... */ var vfForumUSVersion = "3.0.0"; var vfForumUSVersionLetter = "a"; var vfForumUSDeliveryDate = "24052009"; /* Advanced mode */ var advancedModeEnable = GM_getValue("advancedModeEnable","false"); /* Update notifications */ var updateNotificationEnable = GM_getValue("updateNotificationEnable","true"); /* Latest Posts */ var latestPostsEnable = GM_getValue("latestPostsEnable","true"); /* Twitter */ var twitterEnable = GM_getValue("twitterEnable","true"); /* Latest Posts Refresh Interval */ var latestPostsRefreshInterval = GM_getValue("latestPostsRefreshInterval","10"); /* Twitter Refresh Interval */ var twitterRefreshInterval = GM_getValue("twitterRefreshInterval","10"); /* Twitter username*/ var twitterUsername = GM_getValue("twitterUsername","vodafoneNZ"); /* Image resizer */ var imageResizeEnable = GM_getValue("imageResizeEnable","true"); /****************************************************************************************************/ /* Save settings once at start */ /****************************************************************************************************/ var allValues = [ "advancedModeEnable", "latestPostsEnable", "twitterEnable", "latestPostsRefreshInterval", "twitterRefreshInterval", "twitterUsername", "imageResizeEnable", "updateNotificationEnable" ] var allValuesVar = [ advancedModeEnable, latestPostsEnable, twitterEnable, latestPostsRefreshInterval, twitterRefreshInterval, twitterUsername, imageResizeEnable, updateNotificationEnable ] function firstSetAllValues(){ for (i in allValues) { GM_setValue(allValues[i],allValuesVar[i]); } }; function delAllValues(){ for (i in allValues) { GM_deleteValue(allValues[i]); } }; /****************************************************************************************************/ /* Control Panel @ http://forum.vodafone.co.nz/vfforum */ /****************************************************************************************************/ firstSetAllValues(); GM_log("***** AFTER *****"); GM_log(GM_listValues()); if ((window.location == "http://forum.vodafone.co.nz/vfforum" || window.location == "http://forum.vodafone.co.nz/vfforum/") && !($("body").attr("dir"))) { var cssSrc = [ 'http://www.vodafone.co.nz/css/1.2/css/reset.css', 'http://www.vodafone.co.nz/css/1.2/css/main.css' ]; for (i in cssSrc) { var cssAdd = document.createElement('link'); cssAdd.type = 'text/css'; cssAdd.rel = 'stylesheet'; cssAdd.media = 'screen'; cssAdd.href = cssSrc[i]; document.getElementsByTagName('head')[0].appendChild(cssAdd); }; var vfjQueryUICss = GM_getResourceText("vfForumJqueryUI"); addGlobalStyle(vfjQueryUICss); $("body *").remove(); document.title = "Vodafone Forum Improvements User Script Control Panel"; if (GM_getValue("advancedModeEnable") == "true") { /* Advanced interface */ var vfForumAdvancedCPHTML = '

Vodafone Forum Improvements User Script Control Panel

Values are not automatically saved - please click \"Save and Reload\" or \"Save and Exit\".

All changes will take effect on reload.

To exit Advanced Mode, fill "false" into the advancedModeEnable field.

Values:
- checkboxes: "true" / ""
- field: [any value]

'; for (i in allValues) { var vfForumAdvancedCPHTML = vfForumAdvancedCPHTML + ''; } var vfForumAdvancedCPHTML = vfForumAdvancedCPHTML + '
VariableValue
'+allValues[i]+'
'; $("body").append(vfForumAdvancedCPHTML); function advancedCPSaveAll() { for (i in allValues) { var vfAdvancedCPVariableValue = $("input[name="+allValues[i]+"]").val(); switch (vfAdvancedCPVariableValue) { case "false": var vfAdvancedCPVariableValue = false; break; case "true": var vfAdvancedCPVariableValue = true; break; } GM_setValue(allValues[i],vfAdvancedCPVariableValue); } } $("#vfAdvancedCPResetButton").click(function () { delAllValues(); window.location = "http://forum.vodafone.co.nz/"; }); $("#vfAdvancedCPSaveButton").click(function () { advancedCPSaveAll(); window.location = window.location; }); $("#vfAdvancedCPSaveAndExitButton").click(function () { advancedCPSaveAll(); window.location = "http://forum.vodafone.co.nz/"; }); } else { /* Nice interface */ var vfForumCPHTML = '

Vodafone Forum Improvements User Script Control Panel

'+ /* Welcome page */'

Welcome to the Control Panel


Important information to users

This control panel saves settings using Greasemonkey preferences.

This means that when you uninstall and reinstall the script, please make sure that you do not select "Also uninstall associated preferences" otherwise you will lose all settings.


Let\'s get started!

To start editing preferences, click any menu item on the left.

Once you\'ve finished, click \"Save and return to Vodafone Forum\".

'+ /* Forum settings page */''+ /* User script settings page */''+ /* About page */''+ /* REQUIRED - DO NOT EDIT */'
'; $("body").append(vfForumCPHTML); function loadCPPanel(cpPanel){ $(".quadColumn .textContent > div").hide(); $(".quadColumn .textContent #" + cpPanel).show(); }; /* Run through settings */ $("input[name='updateNotificationEnable']").attr("checked",updateNotificationEnable); $("input[name='latestPostsEnable']").attr("checked",latestPostsEnable); $("input[name='twitterEnable']").attr("checked",twitterEnable); $("#latestPostsRefreshInterval").slider({ value: latestPostsRefreshInterval, min: 1, max: 60, step: 1, slide: function(event, ui) { $("#latestPostsRefreshIntervalNumber").text(ui.value); } }); $("#latestPostsRefreshIntervalNumber").text($("#latestPostsRefreshInterval").slider("value")); $("input[name='twitterUsername']").attr("value",twitterUsername); $("input[name='imageResizeEnable']").attr("checked",imageResizeEnable); $("#vfCPWelcomeLink").click(function () { loadCPPanel("vfCPWelcome"); }); $("#vfCPForumSettingsLink").click(function () { loadCPPanel("vfCPForumSettings"); $("#vfCPForumSettingsTabs").tabs(); }); $("#vfCPUSSettingsLink").click(function () { loadCPPanel("vfCPUSSettings"); $("#vfCPUSSettingsTabs").tabs(); }); $("#vfCPAboutLink").click(function () { loadCPPanel("vfCPAbout"); $("#vfCPAboutTabs").tabs(); }); $("#vfCPUSSetingsResetAllLink").click(function () { $("#vfCPUSSetingsResetAllDialog").dialog({ bgiframe: true, resizable: false, height: 180, width: 400, modal: true, overlay: { backgroundColor: '#000', opacity: 0.5 }, title: 'Erase and Reset all settings?', buttons: { Cancel: function() { $(this).dialog('close'); }, 'Erase and Reset all settings': function() { $(this).dialog('close'); /* Delete all preferences */ delAllValues(); window.location = "http://forum.vodafone.co.nz/"; } } }); }); $("#vfCPUSSetingsAdvancedModeLink").click(function () { $("#vfCPUSSetingsAdvancedModeDialog").dialog({ bgiframe: true, resizable: false, height: 180, width: 400, modal: true, overlay: { backgroundColor: '#000', opacity: 0.5 }, title: 'Advanced Mode', buttons: { Cancel: function() { $(this).dialog('close'); }, 'Proceed to Enter Advanced Mode': function() { $(this).dialog('close'); GM_setValue("advancedModeEnable","true"); window.location = window.location; } } }); }); $(".vfCPSetting").change(function() { switch ($(this).attr("type")) { case "text": GM_setValue($(this).attr("name"),$(this).val()); break; case "checkbox": GM_setValue($(this).attr("name"),$(this).attr("checked")); break; default: alert("An error has occured. Redirecting to Vodafone Forum."); window.location = "http://forum.vodafone.co.nz/"; } }); } } else { var vfForumCss = GM_getResourceText("vfForumOnloadCSS"); addGlobalStyle(vfForumCss); };