Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: python builder encoding errors #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions builds/_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,42 +66,42 @@ def trimPath(path):

def SetFirefoxVersion(file_name, new_version):
print('Load install.RDF:\t\t'+file_name);
with open(file_name, 'r') as infile:
with open(file_name, 'r', encoding='utf-8-sig') as infile:
data = infile.read()
data = re.sub(r'(<em:version>)[\d\.]+(</em:version>)', '\g<1>%s\g<2>' % new_version, data)
infile.close()
with open(file_name, 'w') as outfile:
with open(file_name, 'w', encoding='utf-8') as outfile:
outfile.write(data)
outfile.close()


def SetJsonVersion(file_name, new_version):
print('Load *.JSON :\t\t'+file_name);
with open(file_name, 'r') as infile: #
with open(file_name, 'r', encoding='utf-8-sig') as infile: #
data = infile.read()
data = re.sub(r'("version"\s*:\s*)"[\d\.]+"', '\g<1>"%s"' % new_version, data)
infile.close()
with open(file_name, 'w') as outfile:
with open(file_name, 'w', encoding='utf-8') as outfile:
outfile.write(data)
outfile.close()

def SetSafariVersion(file_name, new_version):
print('Load info.plist :\t\t'+file_name);
with open(file_name, 'r') as infile: #
with open(file_name, 'r', encoding='utf-8-sig') as infile: #
data = infile.read()
data = re.sub(r'(<key>(?:CFBundleShortVersionString|CFBundleVersion)</key>[\s\r\n]+?<string>)(?:[\d\.]+?)(</string>)', '\g<1>%s\g<2>' % new_version, data)
infile.close()
with open(file_name, 'w') as outfile:
with open(file_name, 'w', encoding='utf-8') as outfile:
outfile.write(data)
outfile.close()

def SetOperaVersion(file_name, new_version):
print('Load config.XML:\t\t'+file_name);
with open(file_name, 'r') as infile: #
with open(file_name, 'r', encoding='utf-8-sig') as infile: #
data = infile.read()
data = re.sub(r'(<widget[^<>]*?\sversion\s*=\s*)"[\d\.]+"', '\g<1>"%s"' % new_version, data)
infile.close()
with open(file_name, 'w') as outfile:
with open(file_name, 'w', encoding='utf-8') as outfile:
outfile.write(data)
outfile.close()

Expand Down
33 changes: 25 additions & 8 deletions builds/vkopt_script.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ var vkopt_core = {
ge("system_msg").style.visibility = "unset";
topMsg(content, 5);
} catch(e) {
alert(content.replace(/<\/?[^>]+>/,''));
vkopt.log(content.replace(/<\/?[^>]+>/,''));
}
},
run: function(check){
Expand Down Expand Up @@ -3358,6 +3358,7 @@ vkopt['photoview'] = {
photo_search_copy:{},
ph_download_with_name:{},
ph_show_save_info:{default_value: true},
ph_allow_to_profile:{default_value: true},
ph_update_btn:{},
photo_copy_btn:{default_value: true},
pv_hide_comments_btn: {
Expand Down Expand Up @@ -3670,6 +3671,19 @@ vkopt['photoview'] = {

},
onResponseAnswer: function(answer, url, q) {
var LST_IDX = 3;
// Unlock set as profile photo
if (url == 'al_photos.php' && q.act == "show" && answer[LST_IDX] && answer[LST_IDX][0] && answer[LST_IDX][0].id){
if (!vkopt.settings.get('ph_allow_to_profile')) return;
var plist = answer[LST_IDX];
plist.forEach((item, idx) => {
if (item.actions && !item.actions.prof && item.id.split("_").shift() == vk.id) {
item.actions.prof = 1;
item.profile_data = {photo: item.id};
vkopt.log("Add profile_data and prof=1 for " + item.id);
}
});
}
if (url == 'al_photos.php' && q.act == 'save_me' && answer[0]){
if (!vkopt.settings.get('ph_show_save_info')) return;
if (window.cur && cur.pvData){
Expand Down Expand Up @@ -3966,7 +3980,7 @@ vkopt['photos'] = {
pe_hash = cur.pvCurPhoto.peHash;
}

stManager.add(['cmodules/web/upload.js','cmodules/web/filters.js'],function(){
stManager.add([window.jsc("web/upload.js"), window.jsc('web/filters.js')],function(){
var photo=photo_id;
if (/photo-?\d+_\d+/.test(photo)) photo=photo.match(/photo(-?\d+_\d+)/)[1];
dApi.call('photos.getById',{photos:photo, photo_sizes: 1, v:"5.101"}, function(r,items){
Expand Down Expand Up @@ -6185,15 +6199,15 @@ vkopt['scrobbler'] = {
onInit:function(){
var fm=vkopt.scrobbler;
var md5=vkMD5;//from vk_lib.js
fm.token = vkopt.settings.get('lastfm_token');
fm.token = vkopt.settings.get('lastfm_token') || "unset";
fm.username = vkopt.settings.get('lastfm_username');
fm.session_key = vkopt.settings.get('lastfm_session_key');
fm.enable_scrobbling = vkopt.settings.get('lastfm_enable_scrobbling');
function LastFM(options){ // sources: https://github.com/fxb/javascript-last.fm-api
var apiKey=options.apiKey||'';
var apiSecret=options.apiSecret||'';
// https://ws.audioscrobbler.com/2.0/
var apiUrl=options.apiUrl||'http://ws.audioscrobbler.com/2.0/';
var apiUrl=options.apiUrl||'https://ws.audioscrobbler.com/2.0/';
var cache=options.cache||undefined;var debug=typeof(options.debug)=='undefined'?false:options.debug;this.setApiKey=function(_apiKey){apiKey=_apiKey};this.setApiSecret=function(_apiSecret){apiSecret=_apiSecret};this.setApiUrl=function(_apiUrl){apiUrl=_apiUrl};this.setCache=function(_cache){cache=_cache};
//original of library method internalCall with JSONP/iframe requests:
//var internalCall=function(params,callbacks,requestMethod){if(requestMethod=='POST'){var html=document.getElementsByTagName('html')[0];var frameName='lastfmFrame_'+new Date().getTime();var iframe=document.createElement('iframe');html.appendChild(iframe);iframe.contentWindow.name=frameName;iframe.style.display="none";var formState='init';iframe.width=1;iframe.height=1;iframe.style.border='none';iframe.onload=function(){if(formState=='sent'){if(!debug){setTimeout(function(){html.removeChild(iframe);html.removeChild(form)},1500)}};formState='done';if(typeof(callbacks.success)!='undefined'){callbacks.success()}};var form=document.createElement('form');form.target=frameName;form.action=apiUrl;form.method="POST";form.acceptCharset="UTF-8";html.appendChild(form);for(var param in params){var input=document.createElement("input");input.type="hidden";input.name=param;input.value=params[param];form.appendChild(input)};formState='sent';form.submit()}else{var jsonp='jsonp'+new Date().getTime();var hash=auth.getApiSignature(params);if(typeof(cache)!='undefined'&&cache.contains(hash)&&!cache.isExpired(hash)){if(typeof(callbacks.success)!='undefined'){callbacks.success(cache.load(hash))}return}params.callback=jsonp;params.format='json';window[jsonp]=function(data){if(typeof(cache)!='undefined'){var expiration=cache.getExpirationTime(params);if(expiration>0){cache.store(hash,data,expiration)}}if(typeof(data.error)!='undefined'){if(typeof(callbacks.error)!='undefined'){callbacks.error(data.error,data.message)}}else if(typeof(callbacks.success)!='undefined'){callbacks.success(data)}window[jsonp]=undefined;try{delete window[jsonp]}catch(e){}if(head){head.removeChild(script)}};var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");var array=[];for(var param in params){array.push(encodeURIComponent(param)+"="+encodeURIComponent(params[param]))}script.src=apiUrl+'?'+array.join('&').replace(/%20/g,'+');head.appendChild(script)}};
Expand Down Expand Up @@ -6294,7 +6308,7 @@ vkopt['scrobbler'] = {
if (code == 4)// токен сдох
if (!fm.connect_box || !fm.connect_box.isVisible()){
fm.connect_box=vkAlertBox(IDL('AuthBoxTitle'), IDL('AuthBoxText'), function(){
var url = 'http://www.last.fm/api/auth?api_key=' + fm.api_key + '&cb=' + encodeURIComponent(location.protocol+'//' + location.host + '/settings?act=vkscrobbler');
var url = 'https://www.last.fm/api/auth?api_key=' + fm.api_key + '&cb=' + encodeURIComponent(location.protocol+'//' + location.host + '/settings?act=vkscrobbler');
window.open(url,'_blank','');
//location.href = url;
}, function(){
Expand Down Expand Up @@ -12866,7 +12880,7 @@ vkopt['vk_dislike'] = {
</a>');
}
return se('\
<a href="#" dislike_id="'+obj_id+'" class="like_btn post_dislike '+(my_dislike?' '+'pv_disliked':'')+' no_dislikes" onclick="vkopt.vk_dislike.dislike(this.getAttribute(\'dislike_id\')); return false;" onmouseover="vkopt.vk_dislike.dislike_over(this.getAttribute(\'dislike_id\'));" id="post_dislike'+obj_id+'">\
<a href="#" dislike_id="'+obj_id+'" class="PostBottomAction like_btn post_dislike '+(my_dislike?' '+'pv_disliked':'')+' no_dislikes" onclick="vkopt.vk_dislike.dislike(this.getAttribute(\'dislike_id\')); return false;" onmouseover="vkopt.vk_dislike.dislike_over(this.getAttribute(\'dislike_id\'));" id="post_dislike'+obj_id+'">\
<i class="post_dislike_icon" id="dislike_icon'+obj_id+'"></i>\
<span class="post_like_link" id="dislike_link'+obj_id+'">'+IDL('dislike')+'</span>\
<span class="post_like_count fl_l" id="dislike_count'+obj_id+'">'+(count|| '')+'</span>\
Expand Down Expand Up @@ -12894,6 +12908,7 @@ vkopt['vk_dislike'] = {
var attrs=['onclick','onmouseover','onmouseout'];
var types=vkopt.vk_dislike.types;

if (!el) return;
if (hasClass(el,'has_dislike')) return;
addClass(el,'has_dislike');

Expand Down Expand Up @@ -12922,7 +12937,8 @@ vkopt['vk_dislike'] = {
},400)
} else {
//obj_id=(geByTag('i',el)[0] || {}).id;
obj_id = el.outerHTML.split('(this, \'')[1].split('\'')[0];
obj_id = (el.outerHTML.split('(this, \'')[1] || "").split('\'')[0];
if (!obj_id) obj_id = ((el.querySelector("[data-reaction-target-object]") || {}).dataset || {}).reactionTargetObject;
if (!obj_id) return;
//obj_id=obj_id.split('like_icon')[1];
vkopt.vk_dislike.obj_ids.push(obj_id);
Expand Down Expand Up @@ -12967,7 +12983,8 @@ vkopt['vk_dislike'] = {

els=geByClass('like_btns',node);
for (var i=0; i<els.length;i++){
vkopt.vk_dislike.add(geByClass1('like',els[i]));
// vkopt.vk_dislike.add(geByClass1('like',els[i]));
vkopt.vk_dislike.add(els[i].querySelector('.like, .PostButtonReactionsContainer'));
}

els=geByClass('fw_like_wrap',node);
Expand Down