<commit_before>(function () {
    var empty = { branches: [] };

    function findPullRequestLinks() {
	var links = document.getElementsByTagName("a");
	return links;
    }
    function handleBranches(items){
	console.log(items.branches);
    }

    function init(){
	console.log("Content Script");
	chrome.storage.sync.get(empty, handleBranches);
    }

    init();
}());<commit_msg>Rewrite branch URLs that match patterns set from options<commit_after>/*global jQuery */
(function ($) {
    var empty = { branches: [] };

    function rewriteLink(element, branches){
	var $element = $(element),
	    href = $element.attr('href').split("/"),
	    targetBranchPosition = (href.length - 1),
	    targetVal = href[targetBranchPosition],
	    currentBranch,
	    regex,
	    i;

	for(i=0; i< branches.length; i++){
	    currentBranch = branches[i];
	    regex = RegExp(currentBranch.pattern);
	    if (regex.test(targetVal)) {
		href[targetBranchPosition] = currentBranch.target + "..." + targetVal;
	    }
	}

	//Write back
	$element.attr('href', href.join("/"));
    }

    function handleBranches(items){

	function handleLink(index, element){
	    return rewriteLink(element, items.branches);
	}
	$(".recently-pushed-branch-actions a").each(handleLink);
    }

    function init(){
	//This call is async, items is only populated in the callback
	chrome.storage.sync.get(empty, handleBranches);
    }

    init();
}(jQuery));
{'fraction_non_alphanumeric': 0.1550877192982456, 'fraction_numerical': 0.0014035087719298245, 'mean_word_length': 3.5414012738853504, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '614680', 'n_tokens_mistral': 456, 'n_tokens_neox': 431, 'n_words': 95}