Source for "Facebook Wall-to-Wall Links in Mini-Feed"

By Jordon Kalilich
Has 30 other scripts.


// Facebook Wall-to-Wall Links in Mini-Feed, a Greasemonkey user script
// Version 0.1 - March 12, 2008
// Copyright 2007, 2008 Jordon Kalilich (http://www.theworldofstuff.com/)
// Released under the GPL version 3
// http://www.gnu.org/copyleft/gpl.html
//
// ==UserScript==
// @name          Facebook Wall-to-Wall Links in Mini-Feed
// @namespace     http://www.theworldofstuff.com/greasemonkey/
// @description   Adds a link to the wall-to-wall when a user's wall post appears in their minifeed.
// @include       http://*.facebook.com/profile.php?*
// @include       http://*.facebook.com/minifeed.php?*
// ==/UserScript==

updateNotifier();

var minifeed = document.getElementById('minifeed');
if (minifeed) {
   var myID = window.location.href.replace(/.*id=(\d+).*/gi,'$1');
   var childH2s = minifeed.getElementsByTagName('h2');
   for (i = 0; i < childH2s.length; i++) {
      if (childH2s[i].innerHTML.indexOf('\'s wall.') > -1) {
         var theirID = childH2s[i].innerHTML.replace(/.*profile\.php\?id=(\d+).*/gi,'$1');
         childH2s[i].innerHTML = childH2s[i].innerHTML.replace(/'s wall./,'\'s <a href="http://www.facebook.com/wall.php?id='+myID+'&banter_id='+theirID+'">wall</a>.'); 
      }
   }
}

// UPDATE NOTIFIER (Version 8: March 10, 2008)
function updateNotifier() {
var scriptName = "Facebook Wall-to-Wall Links in Mini-Feed";
var shortName = "facebookminifeedwall";
var scriptID = "23862";
var scriptVersion = 0.1;

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 + 3600) { // (number of seconds in 1 hour
   GM_xmlhttpRequest({
    method: 'GET',
    url: 'http://www.theworldofstuff.com/greasemonkey/' + shortName + '.txt',
    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 = '1000'; 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);
           document.getElementById('upgradeLink').addEventListener('click', function(event) {
              notice.parentNode.removeChild(notice);
           }, true);
           document.getElementById('waitLink').addEventListener('click', function(event) {
              event.stopPropagation();
              event.preventDefault();
              alert('You will be notified again in one week.');
              GM_setValue('lastCheck', currentTime + 601200); // 1 week minus 1 hour (will be set after the one below)
              notice.parentNode.removeChild(notice);
           }, true);
           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);
        }
        var linkStyle = 'color: #00f; text-decoration: underline; font: 12px sans-serif';
        if (info.match(/[\d\.]+/)) {
           var versionOnSite = info.match(/[\d\.]+/);
           var updateURL = 'http://userscripts.org/scripts/show/' + scriptID;
           if (info.indexOf(';') > 0) {
              updateURL = info.split(";")[1];
           } 
           if (versionOnSite > scriptVersion) {
              var noticeText = 'An update to the Greasemonkey user script "' + scriptName + '" is available. You are using version ' + scriptVersion + '.<br /><a href="' + updateURL + '" style="' + linkStyle + '; font-weight: bold" id="upgradeLink" target="_blank">Review changes and upgrade to version ' + versionOnSite + '</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" style="' + linkStyle + '; font-weight: normal" id="waitLink">Notify me later</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" style="' + linkStyle + '; font-weight: normal" id="offLink">Turn off these notifications</a>';
              createNotice(noticeText);
           }
        }
        else if (info.indexOf('-') == 0) { // if the script will no longer be maintained
           GM_setValue('checkForUpdates', false);
        }
      }
    }
   });
   GM_setValue('lastCheck', currentTime);
}
}
} // END OF UPDATE NOTIFIER