Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Made by Cerulean#7014. For use of adding extra features into the discord client itself
- function add_to_discord(elm_name, location, icon, title, from_cache) {
- window.button_count = 3;
- icon || (icon = 'https://www.evolutioncycles.co.nz/image/cross.png');
- title || (title = 'Addons');
- from_cache || (from_cache = false);
- var spacer = $('<div style="width: 100%; height: 20px;"></div>');
- var title_element = $('<header>' + title +'</header>');
- var butt = $($($("div[class*='scroller-']")[1]).children()[1]).clone();
- var fixed_button = butt.find('.channel-name').text(elm_name);
- $(butt).find('.channel-name').replaceWith(fixed_button);
- $(butt).find('svg').remove();
- var a = $(butt).find('a').prepend('<img class="link-button-icon" src="' + icon + '"/>');
- $(butt).removeClass('selected');
- $(butt).attr('data-button', '1');
- $(butt).click(function(e) {
- e.preventDefault();
- handle_click(location);
- });
- console.log(window.button_count);
- if (title != 'Addons') {
- $($("div[class*='scroller-']")[1]).insert_at(window.button_count, $(title_element));
- window.button_count = window.button_count + 1;
- };
- $($("div[class*='scroller-']")[1]).insert_at(window.button_count, $(butt));
- window.button_count = window.button_count + 1;
- if (!from_cache) {
- window.buttons.push({name: elm_name, location: location, icon: icon, title: title});
- }
- };
- function handle_click(location) {
- //$($("div[class*='channels-']").siblings()[0]).html('<iframe src="' + location + '" style="height:100%"></iframe>');
- var error_page = '<div style="display:flex;align-items:center;justify-content:center;height:100%;width:100%;flex-flow:column;"><h1 style="color:#fff;">There was an error!</h1><p style="color:#ccc;">We couldnt grab that page due to an error. Please check the console log!</p></div>'
- $.ajax({url: location}).done(function (html) {$($("div[class*='channels-']").siblings()[0]).html(html)}).fail(function () {$($("div[class*='channels-']").siblings()[0]).html($(error_page))});
- $('.channel.selected').removeClass('selected');
- $(this).addClass('selected');
- };
- window.buttons = [];
- function hook_tag () {
- $('a').click(function () {
- var a = $(this);
- setTimeout(function () {
- if ($(a).attr('href') == '/activity') {
- window.buttons.forEach(function (item) {add_to_discord(item.name, item.location, item.icon, item.title, from_cache=true);})
- }
- },150);
- });
- }
- jQuery.fn.insert_at = function(index, element) {
- var lastIndex = this.children().size();
- if (index < 0) {
- index = Math.max(0, lastIndex + 1 + index);
- }
- this.append(element);
- if (index < lastIndex) {
- this.children().eq(index).before(this.children().last());
- }
- return this;
- };
- hook_tag();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement