Greasemonkey/Javascript Help menu

User Tag List

Results 1 to 3 of 3
  1. #1
    DrWho1988's Avatar Elite User
    Reputation
    387
    Join Date
    Oct 2007
    Posts
    554
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Greasemonkey/Javascript Help

    Hi I've been trying to learn JS by messing around with Greasemonkey, tweaking peoples scripts and whatnot. Anyways I'm trying to add a "Like" button from Facebook to the first post of a thread. Yes I know there's the "Share This Thread!" link but like I said I'm using this merely as a self learning tool.
    I think I have the code correct, but apparently not since it doesn't work.

    Maybe someone here can help me out


    Code:
    // ==UserScript==
    // @name          MMOwned Like
    // @namespace     Dr. Watson
    // @description   Like a topic on MMOwned!
    // @include       http://www.mmowned.com/forums/*
    // ==/UserScript==
    
    base_url = getBaseURL();
    
    var base_url = getBaseURL(window.location);
    
    //HTML/CSS added to page
    var like_html = '';
    like_html = '<div style="float: left;"><iframe src="http://www.facebook.com/plugins/like.php?href=' + window.location + '&layout=box_count&show_faces=true&width=450&action=like&font=segoe+ui&colorscheme=dark&height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:65px;" allowTransparency="true"></iframe></div>';
    
    output = document.createElement('div');
    output.innerHTML = like_html;
    
    //add HTML to id posthead
    var op = document.getElementById('posthead');
        op = op.getElementByTagName('a');
        op = op.getElementByName('1');
    if (op) {
            op.parentNode.insertBefore(output, op.nextSibling);
        }
    
    //get url of thread 
    function getBaseURL () {
      var url = location.href;
      var baseURL = url.substring(0, url.indexOf('/', 14));
      
      if (baseURL.indexOf('http://localhost') != -1) {
        var url = location.href;
        var pathname = location.pathname;
        var index1 = url.indexOf(pathname);
        var index2 = url.indexOf("/", index1 + 1);
        var baseLocalUrl = url.substr(0, index2);
    
        return baseLocalUrl + "/";
      }
      else {
        return baseURL + "/";
      }
    }
    Last edited by DrWho1988; 01-24-2011 at 03:45 PM.

    "I am just absolutely convinced that the best formula for giving us peace and preserving the American way of life is freedom, limited government, and minding our own business overseas." - Ron Paul

    Greasemonkey/Javascript Help
  2. #2
    2dgreengiant's Avatar ★ Elder ★


    Reputation
    1190
    Join Date
    Feb 2007
    Posts
    7,129
    Thanks G/R
    1/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you check out the developer page on facebook? It has some references etc u can use i think
    If you need me you have my skype, if you don't have my skype then you don't need me.

  3. #3
    DrWho1988's Avatar Elite User
    Reputation
    387
    Join Date
    Oct 2007
    Posts
    554
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by 2dgreengiant View Post
    Did you check out the developer page on facebook? It has some references etc u can use i think
    Yeah that's where I got the iframe code from. The problem I'm having is that it's either not loading the script at all or its just not inserting the code in the header of the first post. I'm not sure how to debug stuff like this yet

    "I am just absolutely convinced that the best formula for giving us peace and preserving the American way of life is freedom, limited government, and minding our own business overseas." - Ron Paul

Similar Threads

  1. Javascript/JSON help
    By Jaerin in forum Programming
    Replies: 0
    Last Post: 09-09-2012, 10:08 AM
  2. [Javascript/Regex/Greasemonkey]Need help with .replace
    By DrWho1988 in forum Programming
    Replies: 1
    Last Post: 10-28-2010, 10:10 PM
  3. Help WoW Fish-Bot
    By Eliteplague in forum World of Warcraft General
    Replies: 1
    Last Post: 05-07-2006, 08:36 PM
  4. Hit points and talent points? Please help
    By hankusdankus in forum World of Warcraft General
    Replies: 6
    Last Post: 05-04-2006, 02:00 PM
  5. bot help
    By xwhitedeathx in forum World of Warcraft General
    Replies: 3
    Last Post: 05-01-2006, 03:50 AM
All times are GMT -5. The time now is 02:26 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search