Skip to content

Instantly share code, notes, and snippets.

@MorningZ
Last active November 3, 2016 03:22
Show Gist options
  • Save MorningZ/5a06548cd20b244acdeee0e97b839acc to your computer and use it in GitHub Desktop.
Save MorningZ/5a06548cd20b244acdeee0e97b839acc to your computer and use it in GitHub Desktop.
Some hack-y code to spruce up the "new" layout of Team-Integra.net released at the end of May 2016.
*HOPEFULLY* this code won't be needed at all as I hope AutoGuide fixes issues that plague the site as is.
One huge unknown going into using this code: I have no idea what kind of bandwidth limits "imager.com" has,
so if a lot of people use this code, i'm not sure if at some point their site will stop serving the new
updated banner that I am hosting there, so we'll just see !! (I have a backup plan if it's a problem)
Two things are needed to use this code, CSS and JavaScript. If you don't know what those are, that's OK,
you don't really need to other than CSS is for look/design and JavaScript (JS) is for functionality.
Needed:
==========================
Chrome users, you need these two Extensions:
- Stylebot: http://bit.ly/1XDGhX0
- Custom Javascript for websites: http://bit.ly/1Xa0YZx
Firefox users, you'll need these two Add-ons:
- Stylish: https://addons.mozilla.org/en-US/firefox/addon/stylish/
- Greasemonkey: https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/
Safari users:
- Stylish: https://safari-extensions.apple.com/details/?id=com.sobolev.stylish-5555L95H45
- You have to create a site specific extension, details will be below.
Directions:
==========================
Chrome:
- Install Stylebot, click the "css" button button in extension area of Chrome, choose "Open Stylebot"
- In bottom left, choose "Edit CSS" option and paste everything from the below section "CSS"
(as noted by "Start of Copy" and "End of Copy")
- Install the Custom JavaScript extension, click the "cjs" button in extension area of Chrome
- In the top right dropdown, leave it at "-- nothing --"
- Paste the text from the "Javascript" area below into the big text area
Firefox (sorry, a bit more complex):
- Install Stylish and Greasemonkey
- Click the Stylish icon (a square with an "S" inside it) and
choose "Manage Styles", this is where you will go to edit style as well)
- Click the "Write New Style" button at the bottom
- Give this style set a name, anything will work, I'm using "TI - New Layout"
- Paste the everything from the below section "CSS", click "Save", and close the tab that Stylish opened
- Now click the Add-on icon for Greasemonkey, it's a picture of a monkey's head, choose "Manage User Scripts"
- Click on "New User Script" along the top
- Name: TI - New Layout
- Namespace: (leave empty!!)
- Includes: http://www.team-integra.net/* (<--- very important to have it just like this with the "*"
- Click "OK", at the first open line, paste in the text from the "Javascript" section later down this file
- Here is where Greasemonkey is a pain in the ass, when you paste that text in you may get prompted about "unsafe blah blah", you have to type "Allow Paste" like it says and press enter. Once you do that, remove that text and re-paste my code from below
- Click "Save" and close the tab that Greasemonkey opened
- Go back to the tab where the site was and refresh, if you don't see any change, go back to "Manage Script" in Greasemonkey and make sure the script properly got pasted in (it took me two tries when I put these directions together)
(TODO:) Safari:
- Open Stylish by clicking the "S" button in the extension area, choose "Manage".
- Click on the "Edit" button on left pane
- Name this new style "TI - New Layout"
- Paste in the CSS from the section later on down this page
- Set "Applies to:" as "Domain" and "team-integra.net" (EXACTLY that, do not put the "www" even if you browse with that)
- Click "Save Style" in the bottom right
- Close this tab
- Go to "Safari" > "Preferences" > "Advanced" and check the last checkbox "Show Develop menu" and close preference window
- Choose "Develop" from the top menu, then "Extension Builder"
- Click the "+" in bottom left, choose "New Extension" and give this new extension a name of "TI - New Layout"
/*==========================
CSS:
==========================*/
/* Start of Copy/Paste */
#feature-slide { display: none; }
#nav li.mobile-hide { display: none; }
#vB_Editor_001_textarea, #vB_Editor_QR_textarea { width: 650px; }
.ModCount { color: Yellow; }
.info-bar .quick-links li:first-of-type { display: none; }
.mz-forum-name { color: Blue; font-style: normal; margin-right: 8px; text-transform: capitalize; }
[id^=google_ads_iframe] { display: none; }
html body #vB_Editor_QR_controls { max-width: 770px; }
section.articles-list, #Team-Integra_net_728x90_Top_AUTO_Forum, .sidebar.theiaStickySidebar { display: none; }
/* End of Copy/Paste */
/*==========================
Javascript:
==========================*/
/* Start of Copy/Paste */
var MZ = {};
MZ.Settings = {
"ModLinks": {
"Show": false,
"ThreadsUrl": "/forum/moderation.php?do=viewthreads&type=moderated",
"ThreadsCount": 0,
"PostsUrl": "/forum/moderation.php?do=viewposts&type=moderated",
"PostsCount": 0
},
"HomeUrl": "/index.php?page=active_topics",
"ArticlesUrl": "/forum/blogs/recent-entries/",
"BannerUrl": "http://i.imgur.com/wfmRkzS.jpg",
"Storage": {
"Get": function(key) {
if (JSON && typeof(Storage) !== "undefined") {
var obj = localStorage.getItem(key);
if (obj) {
var dt = new Date(); obj = JSON.parse(obj);
alert(obj);
if (dt.getTime() < obj.ts) {
return obj.Value
}
else {
localStorage.setItem(key, null);
}
}
}
return null;
},
"Set": function(key, val, mins) {
if (JSON && typeof(Storage) !== "undefined") {
var dt = new Date(); dt = dt.getTime() + (mins * 1000)
localStorage.setItem(key, JSON.stringify({
"Value": val, "ts": dt
}));
}
}
}
};
// Functions to drive this JS block
MZ.Functions = {
"GetCounts": function(typ) {
var Counts = null; // MZ.Settings.Storage.Get("ModCounts");
//Counts = MZ.Settings.Storage.Get("ModCounts");
if (Counts) {
alert("Pulled from storage");
var lnk = [];
if (Counts.Posts > 0) {
lnk.push('<li class="vbmenu_control tools">');
lnk.push('<a href="' + MZ.Settings.ModLinks.PostsUrl + '" class="ModCount">Mod Posts (' + Counts.Posts + ')</a></li>');
}
if (Counts.Threads > 0) {
lnk.push('<li class="vbmenu_control tools">');
lnk.push('<a href="' + MZ.Settings.ModLinks.ThreadsUrl + '" class="ModCount">Mod Threads (' + Counts.Threads + ')</a></li>');
}
$("#nav").append(lnk.join(''));
}
else {
//alert("Remote call");
$.ajax({
url: MZ.Settings.ModLinks[typ + "Url"],
dataType: 'text',
success: function(data) {
var h = [];
// Look for items needing approval
if (typ === "Posts") {
MZ.Settings.ModLinks.PostsCount = $(data).find("#inlinemodform :checkbox[name*='plist']").length;
}
else {
MZ.Settings.ModLinks.ThreadsCount = $(data).find("#inlinemodform :checkbox[name*='tlist']").length;
}
if (MZ.Settings.ModLinks[typ + "Count"] > 0) {
h.push('<li class="vbmenu_control tools">');
h.push('<a href="' + MZ.Settings.ModLinks[typ + "Url"] + '" class="ModCount">Mod ' + typ + ' (' + MZ.Settings.ModLinks[typ + "Count"] + ')</a></li>');
}
else {
}
$("#nav").append(h.join(''));
// After we got the count for Posts, get the Threads
if (typ === "Posts") {
MZ.Functions.GetCounts("Threads");
}
else {
MZ.Settings.Storage.Set("ModCounts", { "Posts": MZ.Settings.ModLinks.PostsCount, "Threads": MZ.Settings.ModLinks.ThreadsCount }, 2);
}
}
});
}
}
};
jQuery(document).ready(function($) {
// Change top picture
// COMMENTED OUT 06/08 : AutoGuide fixed it !
//$("#header tbody").html('<tr><td><a href="' + MZ.Settings.HomeUrl + '"><img src="' + MZ.Settings.BannerUrl + '" alt=""/></a></td></tr>').closest("table").removeAttr("style").addClass("TI_Header");
// Mod links
if ($(".subnav-bottom a:contains('Mod')").length > 0) { MZ.Functions.GetCounts("Posts"); }
// Hide non mobile links
$("#tmp_mod").hover( function() { $("#menumod_menu").show(); }, function() { $("#menumod_menu").hide(); } );
// Change link for "Home"
$("#nav li:first a").attr("href", MZ.Settings.HomeUrl);
// Change link to "Gallery" to be link to "Articles"
$("#nav li a:contains('Gallery'):first").html("Articles").attr("href", MZ.Settings.ArticlesUrl);
// Break up Notifications
var nh = [];
$.each(['Unread Private Messages', 'Likes Received', 'Post Quotes', 'Mentions'], function(i) {
var $a = $("#notifications_menu table td a:contains('" + this + "')");
var Count = Number($a.closest("tr").find("td:last a").text());
if (Count > 0) {
nh.push('<span class="navbar-subscription">');
nh.push('<a href="' + $a.attr("href") + '" style="font-weight: bold;">' + $a.text().replace("New ", "").replace("Unread Post ", "").replace(" Received", ""));
nh.push('<span style="color: #000"> (' + Count + ')</span>');
nh.push('</a></span>');
}
});
$(".info-bar .welcome-phrase").append(nh.join(''));
// Name of forum from link
switch(window.location.pathname) {
case "/forum/moderation.php":
$("table[id^='post'] .vs_post_original div:first-child a").each(function(i) {
var $a = $(this); var hit = $a.attr("href").match(/^\d+[-]([a-z0-9-_]+)\/.+/);
if (hit && hit.length === 2) {
$a.prepend('<span class="mz-forum-name">' + hit[1].replace("-", " ").replace("_", " ") + ':</span>');
}
});
break;
}
});
/* End of Copy/Paste */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment