Guest User

Untitled

a guest
Jun 5th, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name    Fix Ponilauta report/delete forms
  3. // @description Now without jQuery!
  4. // @include http://*ponilauta.fi/*
  5. // ==/UserScript==
  6.  
  7. window.addEventListener('load', function(){
  8.     "use strict";   // Strict mode for good clean code
  9.  
  10.     // If there are at least three forms on a thread page, the bug has **probably** been fixed.
  11.     // Only checked on thread pages due to inconsistent bug reproducibility in thread listings.
  12.     if (window.location.href.indexOf('/res/') >= 0 && document.getElementsByTagName('form').length >= 3) {
  13.         alert('Report/delete/donate forms have probably been fixed! You may want to delete this user script.')
  14.     }
  15.  
  16.     // Check if there's a problem to fix (both #reportarea and the donate button exist
  17.     if (!!document.getElementById('reportarea') && !!document.getElementsByClassName('content ads')[0]) {
  18.  
  19.         // Create a form for the PayPal button
  20.         var form = document.createElement('form');
  21.             form.setAttribute('action','https://www.paypal.com/cgi-bin/webscr');
  22.             form.setAttribute('method','post');
  23.             form.setAttribute('target','_top');
  24.  
  25.         form.appendChild(document.getElementsByClassName('content ads')[0]);    // Append form contents to the form
  26.         document.body.insertBefore(form, document.getElementById('usercount')); // Insert form to the bottom of page
  27.  
  28.         // Move #reportarea into #delform where it belongs
  29.         document.getElementById('delform').appendChild(document.getElementById('reportarea'));
  30.  
  31.         // Call the set_delpass function to auto-input password
  32.         if (typeof set_delpass == 'function') {
  33.             set_delpass('delform');
  34.         }
  35.     }
  36. }, false);
Advertisement
Add Comment
Please, Sign In to add comment