2011-04-01 121 views
2

everyone。大約一年前,我寫了一個用戶腳本,根據徽章的難度改變了kongregate.com徽章邊框的顏色。此後,他們添加了新功能,現在劇本已被破解。Javascript中的空數組值

在控制檯中拋出的錯誤位於changeBorders(span, difficultyText)函數的第一個條件行:「難度文本未定義」。我回到我的函數調用changeBorders(border, badges[src]);,並且對徽章[src]爲什麼不像以前那樣工作感到困惑。

據我所知,徽章是一個多維數組,存儲圖像的URL(在第二個for循環中指定),並且它相應的難度(在第一個for循環中分配)作爲值對。我很難從這裏走到哪裏。

守則http://pastebin.com/K9Cr6HiE

測試頁http://www.kongregate.com/badges

有人能幫助我找到在我的difficultyText任務失敗的原因?

編輯:Here's where the userscript can be found

+0

我建議的第一件事是進入那裏,並確保**所有**您的本地變量用**'var'正確聲明** – Pointy 2011-04-01 21:57:15

+0

這是完整的腳本嗎?它只是改變邊界?這似乎有點令人費解。爲什麼圖像來源使用「徽章」數組? – 2011-04-02 03:41:58

回答

1

雖然試圖找出這些代碼與什麼改變,我結束了DRY principles

以下測試OK火狐重構它根據;應在Chrome工作太:

setTimeout (SwitchOnPageType, 0); 


function SwitchOnPageType() 
{ 
    //--- Is this an accounts or a badges page? Or neither? 
    var path  = location.pathname; 
    var pathArray = path.split("/"); 

    if(pathArray[1] == "accounts") 
     badgeSetup (true); 

    else if(pathArray[1].indexOf("badges") != -1 | pathArray[1].indexOf("badge_quests") != -1) 
     badgeSetup (false); 
} 


function badgeSetup (bIsAccountsPage) 
{ 
    if (bIsAccountsPage) 
     var badgeImages  = document.querySelectorAll ("div.badge_list div.badge_image"); 
    else 
     var badgeImages  = document.querySelectorAll ("div.badge_image"); 

    for (var J = badgeImages.length-1; J >= 0; --J) 
    { 
     if (bIsAccountsPage) 
     { 
      //--- In this page type, the ID of the node we want is given in a mouseover attribute. 
      var elemWithTextId = badgeImages[J].innerHTML.replace (/(?:.|\n)+(userbadges-\d+_details)(?:.|\n)+/i, "$1"); 
      var elemWithText = document.querySelector ('#' + elemWithTextId + ' span.badge_name'); 
      var difficultyText = elemWithText.innerHTML; 
     } 
     else 
      var difficultyText = badgeImages[J].parentNode.parentNode.title; 

     var borderElem = badgeImages[J].parentNode.querySelector ("div.badge_border span"); 

     changeBorder (borderElem, difficultyText); 
    } 
} 


function changeBorder (borderElement, difficultyText) 
{ 
    /* TO CHANGE A BORDER IMAGE, DELETE THE ENTIRE "data:image" SECTION AND REPLACE 
     IT WITH THE URL OF YOUR IMAGE IN QUOTATION MARKS. 
     Example: "http://img.photobucket.com/albums/v179/Aironi/badge_earned_red_final.png" 
    */ 
    var srchTxtArry  = [ "easy\\s+-\\s+5\\s+points", 
          "medium\\s+-\\s+15\\s+points", 
          "hard\\s+-\\s+30\\s+points", 
          "impossible\\s+-\\s+60\\s+points" 
         ]; 
    var badgeBorderArry = [ "http://www.kingcards.com/images/missu/thm/sadpup_bf8.gif", 
          "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%2C%00%00%00%2C%08%06%00%00%00%1E%84Z%01%00%00%00%09pHYs%00%00%0B%12%00%00%0B%12%01%D2%DD~%FC%00%00%0AOiCCPPhotoshop%20ICC%20profile%00%00x%DA%9DSgTS%E9%16%3D%F7%DE%F4BK%88%80%94KoR%15%08%20RB%8B%80%14%91%26*!%09%10J%88!%A1%D9%15Q%C1%11EE%04%1B%C8%A0%88%03%8E%8E%80%8C%15Q%2C%0C%8A%0A%D8%07%E4!%A2%8E%83%A3%88%8A%CA%FB%E1%7B%A3k%D6%BC%F7%E6%CD%FE%B5%D7%3E%E7%AC%F3%9D%B3%CF%07%C0%08%0C%96H3Q5%80%0C%A9B%1E%11%E0%83%C7%C4%C6%E1%E4.%40%81%0A%24p%00%10%08%B3d!s%FD%23%01%00%F8~%3C%3C%2B%22%C0%07%BE%00%01x%D3%0B%08%00%C0M%9B%C00%1C%87%FF%0F%EAB%99%5C%01%80%84%01%C0t%918K%08%80%14%00%40z%8EB%A6%00%40F%01%80%9D%98%26S%00%A0%04%00%60%CBcb%E3%00P-%00%60'%7F%E6%D3%00%80%9D%F8%99%7B%01%00%5B%94!%15%01%A0%91%00%20%13e%88D%00h%3B%00%AC%CFV%8AE%00X0%00%14fK%C49%00%D8-%000IWfH%00%B0%B7%00%C0%CE%10%0B%B2%00%08%0C%000Q%88%85)%00%04%7B%00%60%C8%23%23x%00%84%99%00%14F%F2W%3C%F1%2B%AE%10%E7*%00%00x%99%B2%3C%B9%249E%81%5B%08-q%07WW.%1E(%CEI%17%2B%146a%02a%9A%40.%C2y%99%192%814%0F%E0%F3%CC%00%00%A0%91%15%11%E0%83%F3%FDx%CE%0E%AE%CE%CE6%8E%B6%0E_-%EA%BF%06%FF%22bb%E3%FE%E5%CF%ABp%40%00%00%E1t~%D1%FE%2C%2F%B3%1A%80%3B%06%80m%FE%A2%25%EE%04h%5E%0B%A0u%F7%8Bf%B2%0F%40%B5%00%A0%E9%DAW%F3p%F8~%3C%3CE%A1%90%B9%D9%D9%E5%E4%E4%D8J%C4B%5Ba%CAW%7D%FEg%C2_%C0W%FDl%F9~%3C%FC%F7%F5%E0%BE%E2%24%812%5D%81G%04%F8%E0%C2%CC%F4L%A5%1C%CF%92%09%84b%DC%E6%8FG%FC%B7%0B%FF%FC%1D%D3%22%C4Ib%B9X*%14%E3Q%12q%8ED%9A%8C%F32%A5%22%89B%92)%C5%25%D2%FFd%E2%DF%2C%FB%03%3E%DF5%00%B0j%3E%01%7B%91-%A8%5Dc%03%F6K'%10Xt%C0%E2%F7%00%00%F2%BBo%C1%D4(%08%03%80h%83%E1%CFw%FF%EF%3F%FDG%A0%25%00%80fI%92q%00%00%5ED%24.T%CA%B3%3F%C7%08%00%00D%A0%81*%B0A%1B%F4%C1%18%2C%C0%06%1C%C1%05%DC%C1%0B%FC%606%84B%24%C4%C2B%10B%0Ad%80%1Cr%60)%AC%82B(%86%CD%B0%1D*%60%2F%D4%40%1D4%C0Qh%86%93p%0E.%C2U%B8%0E%3Dp%0F%FAa%08%9E%C1(%BC%81%09%04A%C8%08%13a!%DA%88%01b%8AX%23%8E%08%17%99%85%F8!%C1H%04%12%8B%24%20%C9%88%14Q%22K%915H1R%8AT%20UH%1D%F2%3Dr%029%87%5CF%BA%91%3B%C8%002%82%FC%86%BCG1%94%81%B2Q%3D%D4%0C%B5C%B9%A87%1A%84F%A2%0B%D0dt1%9A%8F%16%A0%9B%D0r%B4%1A%3D%8C6%A1%E7%D0%ABh%0F%DA%8F%3EC%C70%C0%E8%18%073%C4l0.%C6%C3B%B18%2C%09%93c%CB%B1%22%AC%0C%AB%C6%1A%B0V%AC%03%BB%89%F5c%CF%B1w%04%12%81E%C0%096%04wB%20a%1EAHXLXN%D8H%A8%20%1C%244%11%DA%097%09%03%84Q%C2'%22%93%A8K%B4%26%BA%11%F9%C4%18b21%87XH%2C%23%D6%12%8F%13%2F%10%7B%88C%C47%24%12%89C2'%B9%90%02I%B1%A4T%D2%12%D2F%D2nR%23%E9%2C%A9%9B4H%1A%23%93%C9%DAdk%B2%079%94%2C%20%2B%C8%85%E4%9D%E4%C3%E43%E4%1B%E4!%F2%5B%0A%9Db%40q%A4%F8S%E2(R%CAjJ%19%E5%10%E54%E5%06e%982AU%A3%9AR%DD%A8%A1T%115%8FZB%AD%A1%B6R%AFQ%87%A8%134u%9A9%CD%83%16IK%A5%AD%A2%95%D3%1Ah%17h%F7i%AF%E8t%BA%11%DD%95%1EN%97%D0W%D2%CB%E9G%E8%97%E8%03%F4w%0C%0D%86%15%83%C7%88g(%19%9B%18%07%18g%19w%18%AF%98L%A6%19%D3%8B%19%C7T071%EB%98%E7%99%0F%99oUX*%B6*%7C%15%91%CA%0A%95J%95%26%95%1B*%2FT%A9%AA%A6%AA%DE%AA%0BU%F3U%CBT%8F%A9%5ES%7D%AEFU3S%E3%A9%09%D4%96%ABU%AA%9DP%EBS%1BSg%A9%3B%A8%87%AAg%A8oT%3F%A4~Y%FD%89%06Y%C3L%C3OC%A4Q%A0%B1_%E3%BC%C6%20%0Bc%19%B3x%2C!k%0D%AB%86u%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C%D8%EF%DC%7Fj%C0w%A0%F3%D1%DCG%F7%06%85%83%CF%FE%91%F5%8F%0FC%05%8F%99%8F%CB%86%0D%86%EB%9E8%3E99%E2%3Fr%FD%E9%FC%A7C%CFd%CF%26%9E%17%FE%A2%FE%CB%AE%17%16%2F~%F8%D5%EB%D7%CE%D1%98%D1%A1%97%F2%97%93%BFm%7C%A5%FD%EA%C0%EB%19%AF%DB%C6%C2%C6%1E%BE%C9x31%5E%F4V%FB%ED%C1w%DCw%1D%EF%A3%DF%0FO%E4%7C%20%7F(%FFh%F9%B1%F5S%D0%A7%FB%93%19%93%93%FF%04%03%98%F3%FCc3-%DB%00%00%00%20cHRM%00%00z%25%00%00%80%83%00%00%F9%FF%00%00%80%E9%00%00u0%00%00%EA%60%00%00%3A%98%00%00%17o%92_%C5F%00%00%02%1BIDATx%DA%EC%D91h%13Q%18%07%F0%FF%BB%D4%06%C3%25%1C%C4%D1%40gyqIJ%14%04%AB%A2%AE%92%22%96b%8BY%5C%5CtT%A1%B6%15%E9%EA%A4%EB%89(%C5%10D'%83%82%83%93%90%0E%F2%3Eqq%AA%20%A2%04c%7CV%0F%9B~.%8D%24%E9%5D%A8H%9B%17x%1F%1C%DC%BD%7B%1C%3F%FEw%F7%86%F7%09fF%BB%88(%96Ev%1D%06%95%82%3A%25%A5%7C%DE%BE%16m%B0%20%C10%B8X%B2%00%00g%18%B0%9D%C6%11%22r%FAM%9C%BA5%85z%BD%0E%D7u%11%8F%C7w%04%13%04%01%B4%D6H%A7%D3X%BE%BE%1C9%EF%066%84%80Bh%BAg%AE%1D%C1%87%8F%3F%E1%FB%BE%94R%BE%DD%8D%14%89H%DC%B9%7De%E3s%3D%40%E5%E6%AB%F0%A4%C3%C0%B3K%13%B8%F7%E0%A5%18%D4%EB%AF%96g%F6%3D%A9~%FAr%F7%F2%8B%D0%DF%90%3B%8F%E9%E2qff%0C%FAx%F6%E8%BC%7B%A80%FE%BA%D7%B7%E5%FB%DD%9F%195%E2'%3B%7D%F6%BEN%26c%FD%13.%95J%AC%94J%9A%9003C)%B5%A7X%2C%AEF%26%DCh4%20%A5%FCn%CAR%26%A5%FC%CD%CC%99%CE%B1.%F0N-%5B%FFS%BD%26%07CV%16l%C1%16l%C1%16l%C1%16l%C1%16l%C1%16l%C1%16l%C1%16%BC-p%10%04%C6%01%7BM%5D%60%CF%F3%40D%C7L%C1%12%91%F0%3C%AFkl%CBvk%EEB%0E%B5ZM%98%00%CE%E7%F3%BC%E2%AF%F4%FF%86%C72%09T%CB3%A3%06%A4%7Bq%2C%93%08%B9%D3%B3%FF%0A%05.%1C%1E%7F%3A%C0%1D%CBsJ%A9%83%B3%D3%13%1Cf%8Bl%19%1C%BDT%80%FE%B1%0E%DF%F7G%A4%94%AD%5DJ%15%8F%1F%5E%E57%EF%BEE%B7%0C%E6%B8%E5-R%ECk%D4C%26%E7'%D7%9A%CDf%E2_%9A2Zk%00%80%EB%BA%DB%5E%09%B4%D6H%A5Rk%95%F9J%22j%DE%9Cle%053%0FE%DBk%13%BC%D7%D9%3C%89%0F%016%BD%00%E7%D7%DFN(%11%9D%2C%CB%03%B9E%8A-%19%06%3D%01%E0%FD%02%9CU%00%F83%00%A9%3A%10%0E%94%7F%B9%99%00%00%00%00IEND%AEB%60%82", 
          "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%2C%00%00%00%2C%08%06%00%00%00%1E%84Z%01%00%00%00%09pHYs%00%00%0B%12%00%00%0B%12%01%D2%DD~%FC%00%00%0AOiCCPPhotoshop%20ICC%20profile%00%00x%DA%9DSgTS%E9%16%3D%F7%DE%F4BK%88%80%94KoR%15%08%20RB%8B%80%14%91%26*!%09%10J%88!%A1%D9%15Q%C1%11EE%04%1B%C8%A0%88%03%8E%8E%80%8C%15Q%2C%0C%8A%0A%D8%07%E4!%A2%8E%83%A3%88%8A%CA%FB%E1%7B%A3k%D6%BC%F7%E6%CD%FE%B5%D7%3E%E7%AC%F3%9D%B3%CF%07%C0%08%0C%96H3Q5%80%0C%A9B%1E%11%E0%83%C7%C4%C6%E1%E4.%40%81%0A%24p%00%10%08%B3d!s%FD%23%01%00%F8~%3C%3C%2B%22%C0%07%BE%00%01x%D3%0B%08%00%C0M%9B%C00%1C%87%FF%0F%EAB%99%5C%01%80%84%01%C0t%918K%08%80%14%00%40z%8EB%A6%00%40F%01%80%9D%98%26S%00%A0%04%00%60%CBcb%E3%00P-%00%60'%7F%E6%D3%00%80%9D%F8%99%7B%01%00%5B%94!%15%01%A0%91%00%20%13e%88D%00h%3B%00%AC%CFV%8AE%00X0%00%14fK%C49%00%D8-%000IWfH%00%B0%B7%00%C0%CE%10%0B%B2%00%08%0C%000Q%88%85)%00%04%7B%00%60%C8%23%23x%00%84%99%00%14F%F2W%3C%F1%2B%AE%10%E7*%00%00x%99%B2%3C%B9%249E%81%5B%08-q%07WW.%1E(%CEI%17%2B%146a%02a%9A%40.%C2y%99%192%814%0F%E0%F3%CC%00%00%A0%91%15%11%E0%83%F3%FDx%CE%0E%AE%CE%CE6%8E%B6%0E_-%EA%BF%06%FF%22bb%E3%FE%E5%CF%ABp%40%00%00%E1t~%D1%FE%2C%2F%B3%1A%80%3B%06%80m%FE%A2%25%EE%04h%5E%0B%A0u%F7%8Bf%B2%0F%40%B5%00%A0%E9%DAW%F3p%F8~%3C%3CE%A1%90%B9%D9%D9%E5%E4%E4%D8J%C4B%5Ba%CAW%7D%FEg%C2_%C0W%FDl%F9~%3C%FC%F7%F5%E0%BE%E2%24%812%5D%81G%04%F8%E0%C2%CC%F4L%A5%1C%CF%92%09%84b%DC%E6%8FG%FC%B7%0B%FF%FC%1D%D3%22%C4Ib%B9X*%14%E3Q%12q%8ED%9A%8C%F32%A5%22%89B%92)%C5%25%D2%FFd%E2%DF%2C%FB%03%3E%DF5%00%B0j%3E%01%7B%91-%A8%5Dc%03%F6K'%10Xt%C0%E2%F7%00%00%F2%BBo%C1%D4(%08%03%80h%83%E1%CFw%FF%EF%3F%FDG%A0%25%00%80fI%92q%00%00%5ED%24.T%CA%B3%3F%C7%08%00%00D%A0%81*%B0A%1B%F4%C1%18%2C%C0%06%1C%C1%05%DC%C1%0B%FC%606%84B%24%C4%C2B%10B%0Ad%80%1Cr%60)%AC%82B(%86%CD%B0%1D*%60%2F%D4%40%1D4%C0Qh%86%93p%0E.%C2U%B8%0E%3Dp%0F%FAa%08%9E%C1(%BC%81%09%04A%C8%08%13a!%DA%88%01b%8AX%23%8E%08%17%99%85%F8!%C1H%04%12%8B%24%20%C9%88%14Q%22K%915H1R%8AT%20UH%1D%F2%3Dr%029%87%5CF%BA%91%3B%C8%002%82%FC%86%BCG1%94%81%B2Q%3D%D4%0C%B5C%B9%A87%1A%84F%A2%0B%D0dt1%9A%8F%16%A0%9B%D0r%B4%1A%3D%8C6%A1%E7%D0%ABh%0F%DA%8F%3EC%C70%C0%E8%18%073%C4l0.%C6%C3B%B18%2C%09%93c%CB%B1%22%AC%0C%AB%C6%1A%B0V%AC%03%BB%89%F5c%CF%B1w%04%12%81E%C0%096%04wB%20a%1EAHXLXN%D8H%A8%20%1C%244%11%DA%097%09%03%84Q%C2'%22%93%A8K%B4%26%BA%11%F9%C4%18b21%87XH%2C%23%D6%12%8F%13%2F%10%7B%88C%C47%24%12%89C2'%B9%90%02I%B1%A4T%D2%12%D2F%D2nR%23%E9%2C%A9%9B4H%1A%23%93%C9%DAdk%B2%079%94%2C%20%2B%C8%85%E4%9D%E4%C3%E43%E4%1B%E4!%F2%5B%0A%9Db%40q%A4%F8S%E2(R%CAjJ%19%E5%10%E54%E5%06e%982AU%A3%9AR%DD%A8%A1T%115%8FZB%AD%A1%B6R%AFQ%87%A8%134u%9A9%CD%83%16IK%A5%AD%A2%95%D3%1Ah%17h%F7i%AF%E8t%BA%11%DD%95%1EN%97%D0W%D2%CB%E9G%E8%97%E8%03%F4w%0C%0D%86%15%83%C7%88g(%19%9B%18%07%18g%19w%18%AF%98L%A6%19%D3%8B%19%C7T071%EB%98%E7%99%0F%99oUX*%B6*%7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DCbN%F7%04%EF%D4%E6%F9%A5%90%BD%E2%FC%C7%D6%D8%FE%EER%7F%E0Ze%F1U%B1%11%B43S%9E%BE%8C%FBR%F1%3CyW%CA%18%F1%8F%7D%FE%F2M%E7%F3%E9%1E%A7ED_%AF%D7%99%88%F2%26%EC%F0%7DN%8FT*%95%DF%89%3B%DCj%B5%E0y%DE_SN2%CF%F3%AE%99%B9%14%9D%EB%02%0F%EA%D8z%CE%88%9BR%18%B2a%C1%16l%C1%16l%C1%16l%C1%16l%C1%16l%C1%16l%C1%16l%C1%7D%81%83%200%0E%187u%81%5D%D7%85Rj%C1%14%ACRJ%B8%AE%DB%3D%19%AF%0EJ)%D9%94%DA%9A%94%92%9F%AC%5EN%94r%B8%F8%B9%9D1%60w%F7%26J%B9%87%0Fz%15%8D%CB%B3%D3g%AFX%B1%FCJD%EFwj%F3%FDW%E0%19%E0O%1F%CB%9D%96A%FA%05%B189%5Cy%B4e%20%7C%0E%DDc%91%FE%93%F4i%D6%AB%D5%ABv%BB%9D%FB%9F%A6%8C%D6%1A%00%E08N%DF'%81%D6%1A%85B%E1%EA%D7%E9i.i%DD%11%87SwogX31)%7C%0E%DF%82%99%E1s%98%19%02%EC(%DF%DD%FD%CB%9Fe%9F%C3%03%03%A1%8B%3E%87%E3%1D%E7%ED%00%867%F9%C7%AF%EF%A2%93%00%00%00%00IEND%AEB%60%82", 
          "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%2C%00%00%00%2C%08%06%00%00%00%1E%84Z%01%00%00%00%01sRGB%00%AE%CE%1C%E9%00%00%00%06bKGD%00%FF%00%FF%00%FF%A0%BD%A7%93%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%07tIME%07%D9%0A%18%10%1A2B%24%88%BD%00%00%00%19tEXtComment%00Created%20with%20GIMPW%81%0E%17%00%00%05cIDATX%C3%ED%99%DBoTU%14%87%BF%7Dn%D3%B9%D6%C3%14a%2CJ%AD%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E%13%14%8D%91%00%00%00%00IEND%AEB%60%82" 
         ]; 

    for (J = srchTxtArry.length-1; J >= 0; --J) 
    { 
     var zRegex = new RegExp (srchTxtArry[J], "i"); 
     if (zRegex.test (difficultyText)) 
     { 
      borderElement.style.setProperty ("background", 'url("' + badgeBorderArry[J] + '") no-repeat scroll 0 0 transparent', "important"); 
      break; 
     } 
    } 
} 

注意,我不得不改變一個圖像只是讓這個答案會是下SO 3萬名字符的限制。

+0

這太簡單了。我應該去掉原始代碼,並且只用一個循環就可以重建它,但是希望我能夠拋出衆說紛紜的「補丁」,它會再次運行。我對RegEx還不太滿意,但我會提出的。下學期在我的數據結構類中獲得更多練習。我爲自己添加了一些評論,以便將來的維護更加簡單,所以我可以看到我的原始設計存在缺陷。用戶腳本網址在orig。帖子,並且我將你添加到了信用中。謝謝,布羅克! – KongMD 2011-04-02 12:55:59