Guest User

Untitled

a guest
Dec 21st, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. // ==UserScript==
  2. // @name HVtest
  3. // @namespace HV
  4. // @description HTML replace
  5. // @include http://foorum.hinnavaatlus.ee/*
  6. // @version 1
  7. // ==/UserScript==
  8.  
  9. // lets load jQuery to be sure it's available
  10. function addJQuery(callback) {
  11. var script = document.createElement('script');
  12. script.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js');
  13. script.addEventListener('load', function() {
  14. var script = document.createElement('script');
  15. script.textContent = 'window.jQ=jQuery.noConflict(true);(' + callback.toString() + ')();';
  16. document.body.appendChild(script);
  17. }, false);
  18. document.body.appendChild(script);
  19. }
  20.  
  21. function init() {
  22. // using jQ instead of $ to avoid conflict with the jQuery on the page
  23.  
  24. // METHOD 1:
  25. // We know what elements in html we need to replace iterate thru all of those elements and replace if needed
  26. jQ('a.name').each(function() {
  27. if(jQ(this).html() == 'LiivaneLord') {
  28. jQ(this).html('Olavi');
  29. }
  30. })
  31. }
  32.  
  33. // load jQuery and execute the initialization
  34. addJQuery(init);
Advertisement
Add Comment
Please, Sign In to add comment