您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds post links and quote stuff to Dynasty forums
当前为
// ==UserScript== // @name Dynasty Thingifier // @namespace Alice Cheshire // @include http://dynasty-scans.com/* // @version 1.3.5 // @require http://code.jquery.com/jquery-2.1.4.min.js // @description Adds post links and quote stuff to Dynasty forums // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_listValue // @run-at document-end // ==/UserScript== varinit(); checkpostpage(); genmenu(); menuclicks(); cleardata(); configload(); setuserid(); if (window.isuserpostsurl.match(/http:\/\/dynasty-scans.com\/forum\/posts\?user_id=\d+/)) { window.isuserpostsurl = window.isuserpostsurl.replace(/\d+/, ""); //Replaces the user id in the url } for (i = 0; i < window.postcount; i++){ var id = window.postids[i].toString(); //Temporarily store the post id under the key of 'i' into a variable to use in our next bit if(window.isuserpostsurl !== "http://dynasty-scans.com/forum/posts?user_id=") { $(".time").eq(i).replaceWith("<div class=\"span5 time\"><a href=\"" + window.pageurl + "#" + id + "\">" + $(".time").eq(i).text() + "</a></div>"); //If we're not on the user posts page then we turn all post timestamps on a page into an anchor link } } $('a').hover(function(e) { //When we click a link run this code if ($(e.target).text() == "Quote") { //Make sure that the clicked link is the quote button var quoteid = $(e.target).parents(); //Gets all the parent elements of our link quoteid = quoteid[4]; //Selects the fourth parent which is the .forum_post parent of the link quoteid = $(quoteid).attr('id'); //Gets the id of the .forum_post parent quoteid = "#" + quoteid; //Adds a url anchor sign to the id quoteid = quoteid.toString(); //Converts it to a string to make sure it cooperates GM_setValue("quoteid", window.pageurl + quoteid); var quotename = $(quoteid).find(".user").text(); //Retrieve the quoted user's name quotename = quotename.replace(/Staff|Moderator|Uploader/, ""); //For staff, mods, and uploaders find and remove their title quotename = $.trim(quotename); //Trim the whitespace/newlines off the beginning and end GM_setValue("quotename", quotename); console.log("Quote id: " + GM_getValue("quoteid") + ", Quote name: " + GMgetValue("quotename")); } else { /*This is where code would run if we were doing anything for clicking other links*/ } }); //Checks if we're on the posting page function checkpostpage() { var quoting = pageurl.replace(/http:\/\/dynasty-scans.com\/forum\//, ""); quoting = quoting.replace(/\?.+/, ""); if (quoting === "posts/new") { var post = GM_getValue("quoteid"); var username = GM_getValue("quotename"); console.log(post + "\n" + username); quote = "> [" + username + "](" + post + ") \n> "; message = "\n" + document.getElementById('forum_post_message').value; document.getElementById('forum_post_message').value = quote + message; } } //Initializes our global variables function varinit() { window.pageurl = document.location.toString(); //Stores the entire value of the address bar into a variable window.isuserpostsurl = window.pageurl; //Stores the address variable a second time for use in a different function window.postids = []; //Initializes a blank array for the postids window.postcount = 0; //Counter to keep track of how many posts are on the current page window.pageurl = window.pageurl.replace(/(#.+)/, ""); //Removes any anchors from the stored url so we don't get issues with multiple anchors showing up $('.forum_post').each(function() { window.postids.push(this.id); //For each element of the class forum_post push the element's id to our postids array }); $('.time').each(function(i, obj) { window.postcount++; //This is where we actually count how many posts are on the page }); console.log("Line 81"); var tmp; if (GM_getValue("youruserid", undefined) === undefined) { tmp = "Not set"; } else { tmp = GM_getValue("youruserid", "Not set"); } console.log("Your id: " + tmp); if (tmp.match(/\d+/)) { window.yourid = "http://dynasty-scans.com/forum/posts?user_id=" + GM_getValue("youruserid"); window.useridset = true; console.log("Your id: " + window.yourid + ", ID set? " + window.useridset); } else { window.yourid = "Your user id isn't set!"; window.useridset = false; console.log(window.useridset); } window.configmenustate = true; } function genmenu(){ var menustructure = '\ <style>\ #thingifier * { padding: 0; margin: 0; }\ #thingifier {\ float: left;\ position: fixed;\ top: 45%;\ z-index: 1000000;\ }\ #thingifier-options {\ border: 1px solid black;\ padding: 8px;\ background: aliceblue;\ border-bottom-right-radius: 6px;\ border-left-width: 0;\ }\ #thingifier-options ul { list-style-type: none; margin-left: -4px;}\ #thingifier-options ul > li { vertical-align: middle; }\ #thingifier ul li input { padding-right: 4px; }\ #thingifier-font-size { width: 96px; }\ #thingifier-toggle-button {\ position: absolute;\ top: 0;\ left: calc(100% - 1px);\ width: 24px;\ height: 24px;\ border: 1px solid black;\ background-color: aliceblue;\ color: red;\ border-top-right-radius: 6px;\ border-bottom-right-radius: 6px;\ border-left-width: 0;\ }\ .spoilers-disabled {\ background: #666 none repeat scroll 0% 0%;\ color: #fff;\ }\ .navbar-fixed {\ position: fixed;\ z-index: 1000;\ width: 1210px;\ }\ .pull-right-fixed, .nav-collapse-fixed {\ float: right;\ }\ .nav-padding {\ height: 60px;\ width: 1210px;\ }\ .forum_post_one {\ font-size: 10px !important;\ line-height: 12px !important;\ }\ .forum_post_two {\ font-size: 12px !important;\ line-height: 15px !important;\ }\ .forum_post_three {\ font-size: 16px !important;\ line-height: 19px !important;\ }\ .forum_post_four {\ font-size: 20px !important;\ line-height: 23px !important;\ }\ .forum_post_five {\ font-size: 25px !important;\ line-height: 28px !important;\ }\ </style>\ <div id=\"thingifier\">\ <div id=\"thingifier-options\">\ <ul>\ <li><input type=\"checkbox\" id=\"thingifier-unhide-spoilers\"> Unhide spoilers</li>\ <li><input type=\"checkbox\" id=\"thingifier-fixed-navbar\"> Fixed navbar</li>\ <li><input type=\"checkbox\" id=\"thingifier-pagination\"> Add page selector to top of page</li>\ <li><input type=\"checkbox\" id=\"thingifier-bbcode-buttons\" disabled=\"true\"> Add quick reply and post page bbcode buttons</li>\ <li><input type=\"checkbox\" id=\"thingifier-quote-to-quickreply\" disabled=\"true\"> Quote to quick reply instead of new post page</li>\ <li><input type=\"checkbox\" id=\"thingifier-quote-move-quickreply\" disabled=\"true\"> Move quick reply to under quoted post</li>\ <li><input type=\"range\" id=\"thingifier-font-size\" min=\"1\" max=\"5\"> Change font size <input type=\"button\" id=\"thingifier-reset-font\" value=\"Reset Font Size\"></li>\ <li><a href=\"' + window.yourid + '\" id=\"thingifier-ownposts\"> Your posts</a></li>\ <li><input type="text" id="useridinput"><input type="button" value="Submit user id" id="useridsubmit"></li>\ <li><input type=\"button\" id=\"thingifier-clear\" value=\"Clear stored data\"></li>\ </ul>\ </div>\ <div id=\"thingified-toggle\">\ <input type=\"button" id=\"thingifier-toggle-button\" value=\"X\">\ </div></div>'; $('body').prepend(menustructure); $('#useridinput').hide(); $('#useridsubmit').hide(); if (!window.useridset) { console.log("Checking if user id is set to prepare to replace menu, " + window.useridset); GM_deleteValue("youruserid"); $('#thingifier-ownposts').hide(); $('#useridinput').show(); $('#useridsubmit').show(); setuserid(); } else { console.log("Checking if user id is set to prepare to replace menu, " + window.useridset); } } function setuserid() { console.log("setuserid function is being executed"); $('input#useridsubmit').click(function () { console.log($("input#useridinput").val()); if($("input#useridinput").val().match(/^\d+$/)) { console.log($("input#useridinput").val()); GM_setValue("youruserid", $('input#useridinput').val()); $('#useridinput').hide(); $('#useridsubmit').hide(); $('#thingifier-ownposts').show(); $('#thingifier-ownposts').attr('href', "http://dynasty-scans.com/forum/posts?user_id=" + GM_getValue("youruserid")); } else { GM_deleteValue("youruserid"); console.log($("input#useridinput").val()); $("input#useridinput").val(); $('input#useridinput').val("Invalid user id!"); } }); } function cleardata() { $('#thingifier-clear').click(function() { console.log("Clear button clicked"); var x = window.confirm("Are you sure you want to clear your stored data?"); if (x) { GM_deleteValue("youruserid"); GM_deleteValue("quoteid"); GM_deleteValue("quotename"); GM_deleteValue("spoilers"); GM_deleteValue("navbar"); GM_deleteValue("pagination"); console.log(GM_getValue("youruserid", "Not set")); console.log(GM_getValue("quoteid", "Not set")); console.log(GM_getValue("quotename", "Not set")); console.log(GM_getValue("spoilers", "Not set")); console.log(GM_getValue("navbar", "Not set")); console.log(GM_getValue("pagination", "Not set")); document.location.reload(true); } else { console.log("Decided against it"); } }); } function menuclicks() { $('#thingifier-toggle-button').click(function() { $("#thingifier-options").animate({width:'toggle', height:'toggle'},350); window.configmenustate ^= true; if (window.configmenustate) { $('#thingifier-toggle-button').val('▶'); } else { $('#thingifier-toggle-button').val('◀'); } GM_setValue("configmenustate", window.configmenustate); }); $('#thingifier-unhide-spoilers').click(function() { if ($('#thingifier-unhide-spoilers').is(":checked")) { GM_setValue("spoilers", $('#thingifier-unhide-spoilers').is(":checked")); $('.spoilers').addClass('spoilers-disabled'); } else { GM_setValue("spoilers", $('#thingifier-unhide-spoilers').is(":checked")); $('.spoilers').removeClass('spoilers-disabled'); } }); $('#thingifier-fixed-navbar').click(function() { if ($('#thingifier-fixed-navbar').is(":checked")) { GM_setValue("navbar", $('#thingifier-fixed-navbar').is(":checked")); $('.navbar').addClass('navbar-fixed'); $("<div class=\"nav-padding\"></div>").insertAfter(".navbar"); } else { GM_setValue("navbar", $('#thingifier-fixed-navbar').is(":checked")); $('.navbar').removeClass('navbar-fixed'); $('div.nav-padding').remove(); } }); $('#thingifier-pagination').click(function() { if ($('#thingifier-pagination').is(":checked")) { GM_setValue("pagination", $('#thingifier-pagination').is(":checked")); $("div.pagination").wrap('<div class=\"tmp\">').parent().html(); var tmp = $('div.tmp').html(); $("div.pagination").unwrap(); $('#main').prepend(tmp); } else { GM_setValue("pagination", $('#thingifier-pagination').is(":checked")); $("div.pagination").first().remove(); } }); $('#thingifier-font-size').on('input', function() { window.fontsize = parseInt($(this).val()); console.log(window.fontsize); window.fontclass = "three"; switch (window.fontsize) { case 1: window.fontclass = "one"; break; case 2: window.fontclass = "two"; break; case 3: window.fontclass = "three"; break; case 4: window.fontclass = "four"; break; case 5: window.fontclass = "five"; break; } console.log(window.fontclass); $('.message *').removeClass('forum_post_one'); $('.message *').removeClass('forum_post_two'); $('.message *').removeClass('forum_post_three'); $('.message *').removeClass('forum_post_four'); $('.message *').removeClass('forum_post_five'); $('.message *').addClass('forum_post_' + window.fontclass); GM_setValue('fontsize', window.fontsize); }); $('#thingifier-reset-font').click(function() { $('.message *').removeClass('forum_post_one'); $('.message *').removeClass('forum_post_two'); $('.message *').removeClass('forum_post_three'); $('.message *').removeClass('forum_post_four'); $('.message *').removeClass('forum_post_five'); $('#thingifier-font-size').val(3); GM_deleteValue('fontsize'); }); } function configload() { window.configmenustate = GM_getValue("configmenustate", 1); if (window.configmenustate) { $("#thingifier-options").animate({width:'toggle', height:'toggle'},0); $('#thingifier-toggle-button').val('▶'); } else { $('#thingifier-toggle-button').val('◀'); } window.configspoiler = GM_getValue("spoilers", false); if (window.configspoiler) { $('.spoilers').addClass('spoilers-disabled'); $('#thingifier-unhide-spoilers').prop('checked', true); } window.confignavbar = GM_getValue("navbar", false); if (window.confignavbar ) { $('.navbar').addClass('navbar-fixed'); $("<div class=\"nav-padding\"></div>").insertAfter(".navbar"); $('#thingifier-fixed-navbar').prop('checked', true); } window.configpagination = GM_getValue("pagination", false); if (window.configpagination ) { $("div.pagination").wrap('<div class=\"tmp\">').parent().html(); var tmp = $('div.tmp').html(); $("div.pagination").unwrap(); $('#main').prepend(tmp); $('#thingifier-pagination').prop('checked', true); } window.fontsize = GM_getValue('fontsize', null); console.log(window.fontsize); if (window.fontsize != null) { switch (window.fontsize) { case 1: window.fontclass = "one"; break; case 2: window.fontclass = "two"; break; case 3: window.fontclass = "three"; break; case 4: window.fontclass = "four"; break; case 5: window.fontclass = "five"; break; } console.log(window.fontclass); $('#thingifier-font-size').val(window.fontsize); $('.message *').addClass('forum_post_' + window.fontclass); } }