Source for "MySpace Clean Bulletins"

By Jordon Kalilich
Has 30 other scripts.


// MySpace Clean Bulletins, a Greasemonkey user script
// Version 0.8 - June 19, 2008
// Copyright 2006-2008 Jordon Kalilich (http://www.theworldofstuff.com/)
// Released under the GPL version 3
// http://www.gnu.org/copyleft/gpl.html
//
// ==UserScript==
// @name          MySpace Clean Bulletins
// @namespace     http://www.theworldofstuff.com/greasemonkey/
// @description   Cleans up bulletin pages to make better use of the space.
// @include       http://bulletins.myspace.com/index.cfm?*fuseaction=bulletin.read*
// @include       http://bulletins.myspace.com/index.cfm?*fuseaction=bulletin
// @include       http://bulletins.myspace.com/index.cfm?*fuseaction=bulletin&*
// @include       http://bulletins.myspace.com/Modules/Bulletins/Pages/Index.aspx?*
// @include       http://bulletins.myspace.com/index.cfm?*fuseaction=bulletin.ShowMyBulletins*
// ==/UserScript==

// OPTION: Remove annoying HTML tags from bulletins (big, font, h1-6, small, style).
// Default: true.

var removeAnnoyingTags = true;

// Don't edit below this line unless you know what you're doing.

updateNotifier();

var ad = document.getElementById('tkn_skyscraper');
if (ad) {
   ad.parentNode.removeChild(ad);
}

var location = window.location.href;
if (location.indexOf('bulletin.read') > -1) {
   var readBulletin = document.getElementById('betterb');
   readBulletin.setAttribute('style','width: 920px !important; margin: 0px 15px 10px 15px');
   var from = document.getElementById('read_from');
   from.innerHTML = from.innerHTML.replace(/(<br( \/)?>\s*)*/ig,''); // get rid of extra br's
   if (removeAnnoyingTags == true) {
      var bulletinText = readBulletin.rows[3].cells[1];
      // let's create a dummy variable to do our transformations and reinsert them all at the end. this prevents Firefox from closing tags we haven't closed yet.
      var lala = bulletinText.innerHTML.replace(/<\/?(big|font|small|style)[^>]*>/ig,'') + '';
      // replace h1-6 with block elements
      lala = lala.replace(/<h[1-6][^>]*>/ig,'<span style="display: block !important">') + '';
      lala = lala.replace(/<\/h[1-6][^>]*>/ig,'</span>') + '';
      bulletinText.innerHTML = lala;
      bulletinText.setAttribute('style','font-size: 10pt !important');
   }
   var bulletinTextContainer = document.getElementById('ctl00_cpMain_BulletinRead_ltl_body');
   if (bulletinTextContainer) {
      bulletinTextContainer.setAttribute('style','width: 100% !important');
   }
}
else {
   var bulletinTableWrap = document.evaluate("//div[@class='bulletin_wrap']",document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(0);
   if (bulletinTableWrap) {
      bulletinTableWrap.setAttribute('style','width: 880px !important');
      var tables = bulletinTableWrap.getElementsByTagName('table');
      if (tables) { // probably will be tables
         for (i = 0; i < tables.length; i++) {
            tables[i].setAttribute('style','width: 880px !important');
         }
      }
   }
}

// UPDATE NOTIFIER (Version 12: June 19, 2008)
// Usage Information: http://www.theworldofstuff.com/greasemonkey/updatenotifier.html
function updateNotifier() {
//      PARAMETERS       //
var scriptName = "Myspace Clean Bulletins";
var scriptURL = "http://userscripts.org/scripts/show/5609";
var scriptVersion = 0.8;
var updateURL = "http://www.theworldofstuff.com/greasemonkey/myspacecleanbulletins.txt";
var updateInterval = 3600;
//   END OF PARAMETERS   //
var checkForUpdates = GM_getValue('checkForUpdates', true);
if (checkForUpdates == true) {
var lastCheck = GM_getValue('lastCheck', 0);
var d = new Date();
var currentTime = Math.round(d.getTime() / 1000); // Unix time in seconds
if (currentTime >= lastCheck + updateInterval) {
   GM_xmlhttpRequest({
    method: 'GET',
    url: updateURL,
    headers: {'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey','Accept': 'text/plain',},
    onload: function(responseDetails) {
      if (responseDetails.status == 200) {
        var info = responseDetails.responseText;
        function createNotice(noticeText) {
           var notice = document.createElement('div');
           with (notice.style) { id = 'GMscriptnotice'; position = 'fixed'; top = '0px'; left = '0px'; width = '100%'; background = '#ffeb7c'; zIndex = '50000'; textAlign = 'center'; font = '12px sans-serif'; fontWeight = 'normal'; color = '#000'; padding = '5px 3px 5px 3px'; margin = '0px'; borderTop = '0px'; borderRight = '0px'; borderBottom = '1px solid #beaf5d'; borderLeft = '0px'; }
           notice.innerHTML = noticeText;
           document.getElementsByTagName('body')[0].appendChild(notice);
           if (document.getElementById('offLink')) {
              document.getElementById('offLink').addEventListener('click', function(event) {
                 event.stopPropagation();
                 event.preventDefault();
                 var confirmTurnOff = confirm('Are you sure you no longer want to be notified of updates to this script?');
                 if (confirmTurnOff) {
                    alert('You will no longer be notified of updates to ' + scriptName + '. You can change this preference in about:config.');
                    GM_setValue('checkForUpdates', false);
                    notice.parentNode.removeChild(notice);
                 }
              }, true);
           }
           if (document.getElementById('ignoreLink')) {
              document.getElementById('ignoreLink').addEventListener('click', function(event) {
                 event.stopPropagation();
                 event.preventDefault();
                 alert('You will not be notified until the script is updated again.');
                 GM_setValue('ignoreVersionNumber', versionOnSite.toString());
                 notice.parentNode.removeChild(notice);
              }, true);
           }
           document.getElementById('closeLink').addEventListener('click', function(event) {
              event.stopPropagation();
              event.preventDefault();
              notice.parentNode.removeChild(notice);
           }, true);
        }
        var linkStyle = 'color: #00f; text-decoration: underline; font: 12px sans-serif';
        if (info.match(/^[\d\.]+/)) {
           var ignoreVersionNumber = parseFloat(GM_getValue('ignoreVersionNumber', '0'), 10);
           var versionOnSite = info.match(/[\d\.]+/);
           if (info.indexOf(';') > 0) {
              scriptURL = info.split(";")[1];
           } 
           if ((versionOnSite > scriptVersion) && (versionOnSite > ignoreVersionNumber)) {
              createNotice('An update to the Greasemonkey user script "' + scriptName + '" is available. You are using version ' + scriptVersion + '.<br /><a href="' + scriptURL + '" style="' + linkStyle + '; font-weight: bold" id="upgradeLink">Review changes and upgrade to version ' + versionOnSite + '</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" style="' + linkStyle + '; font-weight: normal" id="ignoreLink">Wait until next version</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" style="' + linkStyle + '; font-weight: normal" id="offLink">Turn off these notifications</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" style="' + linkStyle + '; font-weight: normal" id="closeLink">Close</a>');
           }
        }
        else if (info.indexOf('-') == 0) { // if the script will no longer be maintained
           GM_setValue('checkForUpdates', false);
           if (info.indexOf(';') == 1) {
              scriptURL = info.split(";")[1];
              createNotice('The Greasemonkey user script "' + scriptName + '" will no longer be updated.<br /><a href="' + scriptURL + '" style="' + linkStyle + '; font-weight: bold" id="upgradeLink">More information</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" style="' + linkStyle + '; font-weight: normal" id="closeLink">Close</a>');
           }
        }
      }
    }
   });
   GM_setValue('lastCheck', currentTime);
}
}
} // END OF UPDATE NOTIFIER