From 9952db3a0bc12ddbc0057ed4c0d790f72cb90712 Mon Sep 17 00:00:00 2001 From: Yaroslav Vorobev Date: Fri, 5 Nov 2021 22:05:48 +0300 Subject: [PATCH 1/2] fix: python builder encoding errors --- builds/_builder.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/builds/_builder.py b/builds/_builder.py index 28275587..42a739a0 100644 --- a/builds/_builder.py +++ b/builds/_builder.py @@ -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'()[\d\.]+()', '\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'((?:CFBundleShortVersionString|CFBundleVersion)[\s\r\n]+?)(?:[\d\.]+?)()', '\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'(]*?\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() From cc3625dd793f2ef9485b52f6e7c7addeff9e3cf6 Mon Sep 17 00:00:00 2001 From: Yaroslav Vorobev Date: Fri, 5 Nov 2021 22:07:11 +0300 Subject: [PATCH 2/2] feat: build user script with recent chnages --- builds/vkopt_script.user.js | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/builds/vkopt_script.user.js b/builds/vkopt_script.user.js index a4fa3562..842bd890 100644 --- a/builds/vkopt_script.user.js +++ b/builds/vkopt_script.user.js @@ -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){ @@ -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: { @@ -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){ @@ -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){ @@ -6185,7 +6199,7 @@ 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'); @@ -6193,7 +6207,7 @@ vkopt['scrobbler'] = { 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)}}; @@ -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(){ @@ -12866,7 +12880,7 @@ vkopt['vk_dislike'] = { '); } return se('\ -