Guest
Public paste!

Untitled

By: a guest | Mar 21st, 2010 | Syntax: None | Size: 3.86 KB | Hits: 84 | Expires: Never
Copy text to clipboard
  1. // ==UserScript==
  2. // @name           Atmosphir Forum Adjustments
  3. // @namespace      scupizzaboy
  4. // @include        http://beta.atmosphir.com/atmosphir/forum*
  5. // ==/UserScript==
  6.  
  7.  
  8. // VERSION 1.2
  9.  
  10.  
  11. function userDefined() {
  12.  
  13.     // TURN STUFF ON AND OFF HERE
  14.     // Turn something off by putting // before it
  15.  
  16.     extraSpace();            // Moves Categories below friends, expands some avatars and post space
  17.     allDiscussionsLink();    // Inserts All Discussions link into Categories;
  18.     pmLink();                // Inserts PM link below avatars
  19.  
  20. }
  21.  
  22.  
  23. // NO EDITING BEYOND THIS POINT
  24.  
  25.  
  26.  
  27.  
  28.  
  29. function xpath(query) {
  30.     return document.evaluate(query, document, null,
  31.         XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  32. }
  33.  
  34. function addGlobalStyle(css) {
  35.     var head, style;
  36.     head = document.getElementsByTagName('head')[0];
  37.     if (!head) { return; }
  38.     style = document.createElement('style');
  39.     style.type = 'text/css';
  40.     style.innerHTML = css;
  41.     head.appendChild(style);
  42. }
  43.  
  44. function buildLink(url, text) {
  45.     var link;
  46.     link = document.createElement('a');
  47.     link.setAttribute('href', url);
  48.     link.appendChild(document.createTextNode(text));
  49.     return link;
  50. }
  51.  
  52. function extraSpace() {
  53.     var path, catDiv, friDiv, textDiv;
  54.     catDiv = xpath("//div[@class='categories']").snapshotItem(0);
  55.     friDiv = xpath("//div[@class='friends']").snapshotItem(0);
  56.     if (catDiv && friDiv) {
  57.         friDiv.parentNode.insertBefore(catDiv, friDiv.nextSibling);
  58.         addGlobalStyle(" #contentArea #right-column .right .categories { margin: 10px 10px 0; color: black;} ");
  59.         addGlobalStyle(" #contentArea #right-column .right .categories a { color: #1D83B4; font-weight: bold; } ");
  60.         addGlobalStyle(" #contentArea #right-column .right .categories ul { list-style: none outside none; margin: 0; padding: 0; } ");
  61.         addGlobalStyle(" #contentArea #right-column .right .categories ul li { margin: 0; padding: 0 0 3px; } ");
  62.         addGlobalStyle(" #contentArea #left-column .left .forum-main .inner .main-content { width: 620px; } ");
  63.         addGlobalStyle(" #contentArea #left-column .left .forum-main .inner .main-content .post .post-right { width: 546px; } ");
  64.         addGlobalStyle(" #contentArea #left-column .left .forum-main .inner .main-content .post .post-left { width: 74px; } ");
  65.         path = xpath("//div[@class='main-content']//img[contains(@alt,'avatar')]");
  66.         for (var i = 0; i < path.snapshotLength; i++) {
  67.             path.snapshotItem(i).setAttribute('style', 'width: 64px; height: 64px;');
  68.         }
  69.         textDiv = xpath("//textarea[@class='markItUpEditor']").snapshotItem(0);
  70.         if (textDiv) textDiv.setAttribute('style', 'border: 1px solid rgb(204, 204, 204); height: 300px; width: 98%;');
  71.     }
  72. }
  73.  
  74. function allDiscussionsLink() {
  75.     var catDiv, path, discList;
  76.     catDiv = xpath("//div[@class='categories']").snapshotItem(0);
  77.     if (catDiv) {
  78.         path = catDiv.getElementsByTagName('ul');
  79.         if (path) {
  80.             path = path[0].getElementsByTagName('li');
  81.             if (path) {
  82.                 discList = document.createElement('li');
  83.                 discList.appendChild(buildLink('http://beta.atmosphir.com/atmosphir/forum', 'All Discussions'));
  84.                 path[0].parentNode.insertBefore(discList, path[0]);
  85.             }
  86.         }
  87.     }
  88. }
  89.  
  90. function pmLink() {
  91.     var path, profDiv, str;
  92.     path = xpath("//div[@class='main-content']//div[@class='post-left']//a[contains(@href,'/atmosphir/profile/')]");
  93.     for (var i = 0; i < path.snapshotLength; i++) {
  94.         profDiv = path.snapshotItem(i);
  95.         str = 'http://beta.atmosphir.com/atmosphir/me/mailbox/send?recipients=';
  96.         str += profDiv.getAttribute('href').replace('/atmosphir/profile/', '');
  97.         profDiv.parentNode.appendChild(buildLink(str, 'Send PM'));
  98.     }
  99. }
  100.  
  101. userDefined();
  102.  
  103. // eof