· 5 years ago · Mar 18, 2020, 06:06 PM
1// ==UserScript==
2// @name Sortownik Tematów by Ofkorse
3// @namespace http://ofkorse.xaa.pl/addon/hidetopics.user.js
4// @description Pozwala sortowaÄ tematy w dziale Ĺwiaty Prywatne
5// @include http://www.margonem.pl/?task=forum&show=topics&id=34
6// @include https://www.margonem.pl/?task=forum&show=topics&id=34
7// @version 1.2
8// ==/UserScript==
9
10/*!
11 * jQuery JavaScript Library v1.5.2
12 * http://jquery.com/
13 *
14 * Copyright 2011, John Resig
15 * Dual licensed under the MIT or GPL Version 2 licenses.
16 * http://jquery.org/license
17 *
18 * Includes Sizzle.js
19 * http://sizzlejs.com/
20 * Copyright 2011, The Dojo Foundation
21 * Released under the MIT, BSD, and GPL Licenses.
22 *
23 * Date: Thu Mar 31 15:28:23 2011 -0400
24 */
25/*********************************
26jHistix (ver 1.0.7)
27Copyright 2010, Wojciech Borkowski
28(2011-01-31) (uhutaf@wp.pl)
29**********************************
30Nie wolno usuwaÄďż˝ÄĹźË powyĂĹĄÄšĹszej notatki
31*********************************/
32function getCookie(cookieName) {
33 var returnik = arguments.length > 1 ? arguments[1] : false;
34 var theCookie = "" + document.cookie;
35 var ind = theCookie.indexOf(cookieName);
36 if (ind == -1 || cookieName == "") return returnik;
37 var ind1 = theCookie.indexOf(';', ind);
38 if (ind1 == -1) ind1 = theCookie.length;
39 return unescape(theCookie.substring(ind + cookieName.length + 1, ind1));
40}
41
42function setCookie(cookieName, cookieValue) {
43 if (arguments.length < 2) {
44 return false;
45 }
46 var cook = cookieName + "=" + escape(cookieValue);
47 cookie = arguments.length > 2 ? ";expires=" + arguments[2] : "";
48 document.cookie = cook;
49 return true;
50}
51var d = new Date();
52d.setTime(d.getTime() + 3600000 * 24 * 30);
53
54$(function(){
55 if (window.location.href=="https://www.margonem.pl/?task=forum&show=topics&id=34" || window.location.href=="http://www.margonem.pl/?task=forum&show=topics&id=34")
56 {
57 $("<button name='all'>Wszystkie</button>").css('fontSize','9px').insertAfter("#forum>h2:first").click(function(e){
58 setCookie("sort_temat","false",d);
59 $(".topname").parent("tr").show();
60 });
61 $("<button name='ogolne'>Ogólne</button>").css('fontSize','9px').insertAfter("#forum>h2:first").click(function(e){
62 setCookie("sort_temat","ogolne",d);
63 $(".topname").each(function(){
64 if (!$(this).is("tr:first"))
65 {
66 $(this).parent("tr").hide();
67 var topicname = $(this).children("a:first").text();
68 if (topicname.indexOf("]")==-1) $(this).parent("tr").show();
69 }
70 });
71 });
72 //Skrypcik pobierajÄ
cy nazwy ĹwiatĂłw
73 var yourWorld = [];
74 $(".topname").each(function(){
75 if (!$(this).is("tr:first"))
76 {
77 var topicname = $(this).children("a:first").text();
78 if (topicname.indexOf("]")!=-1)
79 {
80 var world = topicname.slice(topicname.indexOf("[")+1, topicname.indexOf("]"));
81 var isworld = true;
82 world = world.replace(/ /gi,"");
83 for (var i in yourWorld)
84 {
85 if (yourWorld[i]==world) isworld = false;
86 }
87 if (isworld) yourWorld[yourWorld.length] = world;
88 }
89 }
90 });
91 for (var i in yourWorld)
92 {
93 $("<button name='"+yourWorld[i]+"'>"+yourWorld[i]+"</button>").insertAfter("#forum>h2:first").click(function(e){
94 setCookie("sort_temat",$(this).attr("name"),d);
95 $(".topname").each(function(){
96 if (!$(this).is("tr:first"))
97 {
98 $(this).parent("tr").show();
99 var topicname = $(this).children("a:first").text();
100 topicname = topicname.replace(/ /gi,"");
101 var world = topicname.slice(1, topicname.indexOf("]"));
102 if (topicname.indexOf("]")!=-1 && world!=e.target.name) $(this).parent("tr").hide();
103 }
104 });
105 });
106 }
107 var cookieSort = getCookie("sort_temat");
108 if(cookieSort != false && cookieSort != "false"){
109 $("button[name="+cookieSort+"]").click();
110 }
111 $("<span>Sortuj: </span>").attr("tip","<b>Sortownik Tematów</b>Dodatek pozwala na pokazywanie konkretnych tematów w dziale Światy Prywatne.<br><i>Autor: Ofkorse<br>Drobna pomoc: Uhutaf</i>").css('fontSize','10px').insertAfter("#forum>h2:first");
112 }
113});