Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name BlackCats Customizer
- // @description Used to fix problems with Blackcats Games v1.01
- // @match http://www.blackcats-games.net/browse.php*
- // @include http://www.blackcats-games.net/browse.php*
- // ==/UserScript==
- // Used so we can load jQuery before we start our script.
- function main() {
- // Configuration stuff
- var rightIcons = true;
- var resizeBoxart = true;
- // ******* Code following, do not modify **********/
- // Helper Functions
- function addGlobalStyle(CSS) {
- var head = document.getElementsByTagName("head")[0];
- if (!head) {
- alert("NoHead");
- return;
- }
- var style = document.createElement("style");
- style.type = "text/css";
- style.innerHTML = CSS;
- head.appendChild(style);
- }
- function addScript(JS) {
- var head = document.getElementsByTagName("head")[0];
- if (!head) return;
- var script = document.createElement("script");
- script.type = "text/javascript";
- script.innerHTML = JS;
- head.appendChild(script);
- }
- function nextTextNode(obj) {
- var i = 0;
- while(obj.nodeType != 3 || obj.data.trim() == "" && i++ < 100)
- obj = obj.nextSibling;
- if (i == 100) obj = null;
- return obj;
- }
- // Inject our own CSS
- addGlobalStyle("\
- .new {color: #ff0000; font-weight: bold;}\
- .torrentlink {clear: both; font-weight: bold;}\
- .imglink {padding-left: 5px; padding-right: 5px; float: right;}\
- .date {color: #cccccc; font-style: italic; display: block;}\
- ");
- // Layout Variables
- var Search = false;
- var Theme = "ICGStation";
- // Determine theme
- var Stylesheet = document.getElementsByTagName("link")[0];
- if (Stylesheet.href == "http://www.blackcats-games.net/themes/ICGstation/ICGstation.css") {
- Theme = "ICGStation";
- } else if (Stylesheet.href == "http://www.blackcats-games.net/themes/naito/naito.css") {
- Theme = "Naito";
- }
- // Check if we're searching
- if (window.location.href.indexOf('search') != -1)
- Search = true;
- // Find the table that contains the torrent list.
- var ConTables = document.getElementById("pagescontainer").getElementsByTagName("table");
- var TorrentList = null;
- for (var i = 0; i < ConTables.length; i++) {
- // Fetch the inner text of the first td tag.
- var InText = ConTables[i].getElementsByTagName("td")[0].innerText;
- // "BoxArt" means we found the torrent list.
- if (InText != "Boxart") continue;
- TorrentList = ConTables[i].getElementsByTagName("tr");
- break;
- }
- // Enter block if we found the list of torrents
- if (TorrentList != null) {
- for (var i = 1; i < TorrentList.length; i++) {
- // Easiest way to re-arrange the box is rebuild it!
- if (rightIcons) {
- // Get data
- tData = TorrentList[i].getElementsByTagName("td")[2];
- tLinks = tData.getElementsByTagName("a");
- torrentSticky = false;
- if (tLinks[0].getElementsByTagName("img").length != 0)
- torrentSticky = true;
- torrentName = tLinks[0].innerText;
- torrentLink = tLinks[0].href;
- torrentNew = false;
- if (tData.getElementsByTagName("img")[0].src == "http://www.blackcats-games.net/pic/new.png" ||
- tData.getElementsByTagName("img")[1].src == "http://www.blackcats-games.net/pic/new.png")
- torrentNew = true;
- torrentDownload = tLinks[1].href;
- torrentBookmark = tLinks[2].href;
- torrentDate = nextTextNode(tLinks[0]).data;
- var td = document.createElement("td");
- // Torrent Link
- var newTorrentData = '';
- var link = '<a href="' + torrentLink + '" class="torrentlink">' + torrentName;
- if (torrentNew)
- link += ' (<span class="new">NEW</span>)';
- if (torrentSticky)
- link = '<img class="imglink" src="http://www.blackcats-games.net/pic/sticky.gif"/>' + link;
- link += '</a></b>';
- newTorrentData = link;
- // Torrent Upload Date
- var upload = '<span class="date">' + torrentDate + '</span>';
- newTorrentData += upload;
- // Download/Bookmark links
- var download = '<a href="' + torrentDownload + '"><img src="pic/save.PNG" class="imglink" /></a>';
- newTorrentData += download;
- var bookmark = '<a href="' + torrentBookmark + '"><img src="/pic/book_open.png" class="imglink" /></a>';
- newTorrentData += bookmark;
- td.innerHTML = newTorrentData;
- TorrentList[i].replaceChild(td, tData);
- }
- if (resizeBoxart) {
- boxArt = TorrentList[i].getElementsByTagName("td")[0].getElementsByTagName("img")[0];
- boxArt.style.height = "64px";
- boxArt.style.width = "64px";
- }
- }
- }
- }
- // Load jQuery using a callback workaround for Chrome. Thanks to Erik Vold (http://erikvold.com/blog/index.cfm/2010/6/14/using-jquery-with-a-user-script)
- function loadJQuery(callback) {
- var jq = document.createElement("script");
- jq.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
- jq.addEventListener('load', function() {
- var script = document.createElement("script");
- script.textContent = "(" + callback + ")();";
- document.body.appendChild(script);
- }, false);
- document.body.appendChild(jq);
- }
- // Load jQuery and execute main()
- loadJQuery(main);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement